controls/DebugVariablePanel.py
author Laurent Bessard
Wed, 06 Feb 2013 01:18:56 +0100
changeset 925 5f9dd88a605b
parent 924 5f2cc382be8c
child 927 bd3e5b65e8be
permissions -rw-r--r--
Added support for drag'n drop variable from one graph to another with visible graph
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
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
    25
from types import TupleType, ListType, FloatType
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
    26
from time import time as gettime
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
    27
import math
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
    28
import numpy
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    29
import binascii
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    30
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    31
import wx
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    32
import wx.lib.buttons
888
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
    33
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
    34
try:
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
    35
    import matplotlib
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
    36
    matplotlib.use('WX')
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
    37
    import matplotlib.pyplot
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
    38
    from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
    39
    from matplotlib.backends.backend_wxagg import _convert_agg_to_wx_bitmap
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
    40
    from matplotlib.backends.backend_agg import FigureCanvasAgg
888
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
    41
    from mpl_toolkits.mplot3d import Axes3D
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
    42
    USE_MPL = True
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
    43
except:
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
    44
    USE_MPL = False
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
    45
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
    46
from graphics import DebugDataConsumer, DebugViewer, REFRESH_PERIOD
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    47
from controls import CustomGrid, CustomTable
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    48
from dialogs.ForceVariableDialog import ForceVariableDialog
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    49
from util.BitmapLibrary import GetBitmap
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    50
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    51
def AppendMenu(parent, help, id, kind, text):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    52
    parent.Append(help=help, id=id, kind=kind, text=text)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    53
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    54
def GetDebugVariablesTableColnames():
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    55
    _ = lambda x : x
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
    56
    return [_("Variable"), _("Value")]
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    57
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    58
CRC_SIZE = 8
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    59
CRC_MASK = 2 ** CRC_SIZE - 1
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    60
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    61
class VariableTableItem(DebugDataConsumer):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    62
    
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
    63
    def __init__(self, parent, variable):
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    64
        DebugDataConsumer.__init__(self)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    65
        self.Parent = parent
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    66
        self.Variable = variable
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
    67
        self.RefreshVariableType()
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
    68
        self.Value = ""
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
    69
        
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    70
    def __del__(self):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    71
        self.Parent = None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    72
    
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    73
    def SetVariable(self, variable):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    74
        if self.Parent and self.Variable != variable:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    75
            self.Variable = variable
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
    76
            self.RefreshVariableType()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
    77
            self.Parent.RefreshView()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
    78
    
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    79
    def GetVariable(self, mask=None):
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
    80
        variable = self.Variable
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    81
        if mask is not None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    82
            parts = variable.split('.')
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    83
            mask = mask + ['*'] * max(0, len(parts) - len(mask))
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    84
            last = None
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    85
            variable = ""
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    86
            for m, v in zip(mask, parts):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    87
                if m == '*':
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    88
                    if last == '*':
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    89
                        variable += '.'
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    90
                    variable += v
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    91
                elif last is None or last == '*':
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    92
                    variable += '..'
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
    93
                last = m
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
    94
        return variable
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    95
    
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
    96
    def RefreshVariableType(self):
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
    97
        self.VariableType = self.Parent.GetDataType(self.Variable)
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
    98
        if USE_MPL:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
    99
            self.ResetData()
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   100
    
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   101
    def GetVariableType(self):
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   102
        return self.VariableType
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   103
    
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   104
    def GetData(self, start_tick=None, end_tick=None):
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   105
        if USE_MPL and self.IsNumVariable():
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   106
            if len(self.Data) == 0:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   107
                return self.Data
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   108
            
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   109
            start_idx = end_idx = None
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   110
            if start_tick is not None:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   111
                start_idx = self.GetNearestData(start_tick, -1)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   112
            if end_tick is not None:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   113
                end_idx = self.GetNearestData(end_tick, 1)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   114
            if start_idx is None:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   115
                start_idx = 0
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   116
            if end_idx is not None:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   117
                return self.Data[start_idx:end_idx + 1]
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   118
            else:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   119
                return self.Data[start_idx:]
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   120
            
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   121
        return None
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   122
    
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   123
    def GetRawValue(self, idx):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   124
        if self.VariableType in ["STRING", "WSTRING"] and idx < len(self.RawData):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   125
            return self.RawData[idx][0]
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   126
        return ""
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   127
    
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   128
    def GetRange(self):
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   129
        return self.MinValue, self.MaxValue
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   130
    
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   131
    def ResetData(self):
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   132
        if self.IsNumVariable():
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   133
            self.Data = numpy.array([]).reshape(0, 3)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   134
            if self.VariableType in ["STRING", "WSTRING"]:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   135
                self.RawData = []
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   136
            self.MinValue = None
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   137
            self.MaxValue = None
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   138
        else:
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   139
            self.Data = None
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   140
    
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   141
    def IsNumVariable(self):
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   142
        return (self.Parent.IsNumType(self.VariableType) or 
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   143
                self.VariableType in ["STRING", "WSTRING"])
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   144
    
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   145
    def NewValue(self, tick, value, forced=False):
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   146
        if USE_MPL and self.IsNumVariable():
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   147
            if self.VariableType in ["STRING", "WSTRING"]:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   148
                num_value = binascii.crc32(value) & CRC_MASK
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   149
            else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   150
                num_value = float(value)
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   151
            if self.MinValue is None:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   152
                self.MinValue = num_value
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   153
            else:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   154
                self.MinValue = min(self.MinValue, num_value)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   155
            if self.MaxValue is None:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   156
                self.MaxValue = num_value
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   157
            else:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   158
                self.MaxValue = max(self.MaxValue, num_value)
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   159
            forced_value = float(forced)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   160
            if self.VariableType in ["STRING", "WSTRING"]:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   161
                raw_data = (value, forced_value)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   162
                if len(self.RawData) == 0 or self.RawData[-1] != raw_data:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   163
                    extra_value = len(self.RawData)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   164
                    self.RawData.append(raw_data)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   165
                else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   166
                    extra_value = len(self.RawData) - 1
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   167
            else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   168
                extra_value = forced_value
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   169
            self.Data = numpy.append(self.Data, [[float(tick), num_value, extra_value]], axis=0)
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   170
            self.Parent.HasNewData = True
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   171
        DebugDataConsumer.NewValue(self, tick, value, forced)
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   172
    
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   173
    def SetForced(self, forced):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   174
        if self.Forced != forced:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   175
            self.Forced = forced
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   176
            self.Parent.HasNewData = True
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   177
    
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   178
    def SetValue(self, value):
892
771581a6b0be Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents: 888
diff changeset
   179
        if (self.VariableType == "STRING" and value.startswith("'") and value.endswith("'") or
771581a6b0be Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents: 888
diff changeset
   180
            self.VariableType == "WSTRING" and value.startswith('"') and value.endswith('"')):
771581a6b0be Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents: 888
diff changeset
   181
            value = value[1:-1]
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   182
        if self.Value != value:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   183
            self.Value = value
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   184
            self.Parent.HasNewData = True
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   185
            
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   186
    def GetValue(self, tick=None, raw=False):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   187
        if tick is not None and self.IsNumVariable() and len(self.Data) > 0:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   188
            idx = numpy.argmin(abs(self.Data[:, 0] - tick))
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   189
            if self.VariableType in ["STRING", "WSTRING"]:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   190
                value, forced = self.RawData[int(self.Data[idx, 2])]
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   191
                if not raw:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   192
                    if self.VariableType == "STRING":
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   193
                        value = "'%s'" % value
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   194
                    else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   195
                        value = '"%s"' % value
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   196
                return value, forced
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   197
            else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   198
                value = self.Data[idx, 1]
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   199
                if not raw and isinstance(value, FloatType):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   200
                    value = "%.6g" % value
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   201
                return value, self.IsForced()
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   202
        elif not raw:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   203
            if self.VariableType == "STRING":
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   204
                return "'%s'" % self.Value
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   205
            elif self.VariableType == "WSTRING":
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   206
                return '"%s"' % self.Value
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   207
            elif isinstance(self.Value, FloatType):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   208
                return "%.6g" % self.Value
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   209
        return self.Value
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   210
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   211
    def GetNearestData(self, tick, adjust):
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   212
        if USE_MPL and self.IsNumVariable():
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   213
            ticks = self.Data[:, 0]
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   214
            new_cursor = numpy.argmin(abs(ticks - tick))
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   215
            if adjust == -1 and ticks[new_cursor] > tick and new_cursor > 0:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   216
                new_cursor -= 1
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   217
            elif adjust == 1 and ticks[new_cursor] < tick and new_cursor < len(ticks):
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   218
                new_cursor += 1
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   219
            return new_cursor
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   220
        return None
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   221
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   222
class DebugVariableTable(CustomTable):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   223
    
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   224
    def GetValue(self, row, col):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   225
        if row < self.GetNumberRows():
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   226
            return self.GetValueByName(row, self.GetColLabelValue(col, False))
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   227
        return ""
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   228
    
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   229
    def SetValue(self, row, col, value):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   230
        if col < len(self.colnames):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   231
            self.SetValueByName(row, self.GetColLabelValue(col, False), value)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   232
            
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   233
    def GetValueByName(self, row, colname):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   234
        if row < self.GetNumberRows():
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   235
            if colname == "Variable":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   236
                return self.data[row].GetVariable()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   237
            elif colname == "Value":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   238
                return self.data[row].GetValue()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   239
        return ""
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   240
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   241
    def SetValueByName(self, row, colname, value):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   242
        if row < self.GetNumberRows():
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   243
            if colname == "Variable":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   244
                self.data[row].SetVariable(value)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   245
            elif colname == "Value":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   246
                self.data[row].SetValue(value)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   247
    
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   248
    def IsForced(self, row):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   249
        if row < self.GetNumberRows():
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   250
            return self.data[row].IsForced()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   251
        return False
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   252
    
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   253
    def IsNumVariable(self, row):
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   254
        if row < self.GetNumberRows():
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   255
            return self.data[row].IsNumVariable()
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   256
        return False
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   257
    
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   258
    def _updateColAttrs(self, grid):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   259
        """
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   260
        wx.grid.Grid -> update the column attributes to add the
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   261
        appropriate renderer given the column name.
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   262
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   263
        Otherwise default to the default renderer.
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   264
        """
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   265
        
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   266
        for row in range(self.GetNumberRows()):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   267
            for col in range(self.GetNumberCols()):
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   268
                colname = self.GetColLabelValue(col, False)
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   269
                if colname == "Value":
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   270
                    if self.IsForced(row):
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   271
                        grid.SetCellTextColour(row, col, wx.BLUE)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   272
                    else:
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   273
                        grid.SetCellTextColour(row, col, wx.BLACK)
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   274
                grid.SetReadOnly(row, col, True)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   275
            self.ResizeRow(grid, row)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   276
                
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   277
    def AppendItem(self, data):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   278
        self.data.append(data)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   279
    
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   280
    def InsertItem(self, idx, data):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   281
        self.data.insert(idx, data)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   282
    
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   283
    def RemoveItem(self, idx):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   284
        self.data.pop(idx)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   285
    
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   286
    def MoveItem(self, idx, new_idx):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   287
        self.data.insert(new_idx, self.data.pop(idx))
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   288
        
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   289
    def GetItem(self, idx):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   290
        return self.data[idx]
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   291
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   292
class DebugVariableDropTarget(wx.TextDropTarget):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   293
    
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   294
    def __init__(self, parent, control=None):
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   295
        wx.TextDropTarget.__init__(self)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   296
        self.ParentWindow = parent
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   297
        self.ParentControl = control
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   298
    
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   299
    def __del__(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   300
        self.ParentWindow = None
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   301
        self.ParentControl = None
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   302
    
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   303
    def OnDropText(self, x, y, data):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   304
        message = None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   305
        try:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   306
            values = eval(data)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   307
        except:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   308
            message = _("Invalid value \"%s\" for debug variable")%data
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   309
            values = None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   310
        if not isinstance(values, TupleType):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   311
            message = _("Invalid value \"%s\" for debug variable")%data
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   312
            values = None
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   313
        
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   314
        if message is not None:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   315
            wx.CallAfter(self.ShowMessage, message)
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   316
        elif values is not None and values[1] == "debug":
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   317
            if isinstance(self.ParentControl, CustomGrid):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   318
                x, y = self.ParentControl.CalcUnscrolledPosition(x, y)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   319
                row = self.ParentControl.YToRow(y - self.ParentControl.GetColLabelSize())
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   320
                if row == wx.NOT_FOUND:
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   321
                    row = self.ParentWindow.Table.GetNumberRows()
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   322
                self.ParentWindow.InsertValue(values[0], row, force=True)
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   323
            elif self.ParentControl is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   324
                width, height = self.ParentControl.Canvas.GetSize()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   325
                target_idx = self.ParentControl.GetIndex()
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   326
                merge_type = GRAPH_PARALLEL
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   327
                if self.ParentControl.Is3DCanvas():
919
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   328
                    if y > height / 2:
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   329
                        target_idx += 1
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   330
                    if len(values) > 2 and values[2] == "move":
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   331
                        self.ParentWindow.MoveGraph(values[0], target_idx)
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   332
                    else:
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   333
                        self.ParentWindow.InsertValue(values[0], target_idx, force=True)
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   334
                else:
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   335
                    rect = self.ParentControl.GetAxesBoundingBox()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   336
                    if rect.InsideXY(x, y):
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   337
                        merge_rect = wx.Rect(rect.x, rect.y, rect.width / 2., rect.height)
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   338
                        if merge_rect.InsideXY(x, y):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   339
                            merge_type = GRAPH_ORTHOGONAL
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   340
                        wx.CallAfter(self.ParentWindow.MergeGraphs, values[0], target_idx, merge_type, force=True)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   341
                    else:
919
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   342
                        if y > height / 2:
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   343
                            target_idx += 1
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   344
                        if len(values) > 2 and values[2] == "move":
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   345
                            self.ParentWindow.MoveGraph(values[0], target_idx)
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   346
                        else:
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   347
                            self.ParentWindow.InsertValue(values[0], target_idx, force=True)
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   348
            elif len(values) > 2 and values[2] == "move":
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   349
                self.ParentWindow.MoveGraph(values[0])
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   350
            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   351
                self.ParentWindow.InsertValue(values[0], force=True)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   352
            
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   353
    def ShowMessage(self, message):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   354
        dialog = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   355
        dialog.ShowModal()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   356
        dialog.Destroy()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   357
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   358
if USE_MPL:
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   359
    MILLISECOND = 1000000
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   360
    SECOND = 1000 * MILLISECOND
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   361
    MINUTE = 60 * SECOND
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   362
    HOUR = 60 * MINUTE
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   363
    DAY = 24 * HOUR
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   364
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   365
    ZOOM_VALUES = map(lambda x:("x %.1f" % x, x), [math.sqrt(2) ** i for i in xrange(8)])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   366
    RANGE_VALUES = map(lambda x: (str(x), x), [25 * 2 ** i for i in xrange(6)])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   367
    TIME_RANGE_VALUES = [("%ds" % i, i * SECOND) for i in (1, 2, 5, 10, 20, 30)] + \
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   368
                        [("%dm" % i, i * MINUTE) for i in (1, 2, 5, 10, 20, 30)] + \
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   369
                        [("%dh" % i, i * HOUR) for i in (1, 2, 3, 6, 12, 24)]
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   370
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   371
    GRAPH_PARALLEL, GRAPH_ORTHOGONAL = range(2)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   372
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   373
    SCROLLBAR_UNIT = 10
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   374
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   375
    def NextTick(variables):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   376
        next_tick = None
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   377
        for item, data in variables:
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   378
            if len(data) > 0:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   379
                if next_tick is None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   380
                    next_tick = data[0][0]
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   381
                else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   382
                    next_tick = min(next_tick, data[0][0])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   383
        return next_tick
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   384
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   385
    def OrthogonalData(item, start_tick, end_tick):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   386
        data = item.GetData(start_tick, end_tick)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   387
        min_value, max_value = item.GetRange()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   388
        if min_value is not None and max_value is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   389
            center = (min_value + max_value) / 2.
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   390
            range = max(1.0, max_value - min_value)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   391
        else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   392
            center = 0.5
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   393
            range = 1.0
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   394
        return data, center - range * 0.55, center + range * 0.55
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   395
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   396
    class DebugVariableViewer(wx.Panel):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   397
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   398
        def AddViewer(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   399
            pass
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   400
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   401
        def AddButtons(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   402
            pass
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   403
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   404
        def __init__(self, parent, window, items=[]):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   405
            wx.Panel.__init__(self, parent)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   406
            self.SetBackgroundColour(wx.WHITE)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   407
            self.SetDropTarget(DebugVariableDropTarget(window, self))
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   408
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   409
            self.ParentWindow = window
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   410
            self.Items = items
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   411
            self.ResetVariableNameMask()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   412
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   413
            self.MainSizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   414
            self.AddViewer()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   415
            self.AddButtons()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   416
            self.MainSizer.AddGrowableCol(0)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   417
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   418
            self.SetSizer(self.MainSizer)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   419
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   420
        def __del__(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   421
            self.ParentWindow = None
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   422
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   423
        def GetIndex(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   424
            return self.ParentWindow.GetViewerIndex(self)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   425
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   426
        def GetItem(self, variable):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   427
            for item in self.Items:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   428
                if item.GetVariable() == variable:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   429
                    return item
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   430
            return None
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   431
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   432
        def GetItems(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   433
            return self.Items
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   434
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   435
        def GetVariables(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   436
            if len(self.Items) > 1:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   437
                variables = [item.GetVariable() for item in self.Items]
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   438
                if self.GraphType == GRAPH_ORTHOGONAL:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   439
                    return tuple(variables)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   440
                return variables
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   441
            return self.Items[0].GetVariable()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   442
        
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   443
        def ResetVariableNameMask(self):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   444
            if len(self.Items) > 1:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   445
                self.VariableNameMask = reduce(compute_mask,
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   446
                    [item.GetVariable().split('.') for item in self.Items])
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   447
            elif len(self.Items) > 0:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   448
                self.VariableNameMask = self.Items[0].GetVariable().split('.')[:-1] + ['*']
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   449
            else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   450
                self.VariableNameMask = []
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   451
        
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   452
        def AddItem(self, item):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   453
            self.Items.append(item)
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   454
            self.ResetVariableNameMask()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   455
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   456
        def RemoveItem(self, item):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   457
            if item in self.Items:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   458
                self.Items.remove(item)
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   459
            self.ResetVariableNameMask()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   460
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   461
        def Clear(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   462
            for item in self.Items:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   463
                self.ParentWindow.RemoveDataConsumer(item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   464
            self.Items = []
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   465
            self.ResetVariableNameMask()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   466
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   467
        def IsEmpty(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   468
            return len(self.Items) == 0
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   469
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   470
        def UnregisterObsoleteData(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   471
            for item in self.Items[:]:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   472
                iec_path = item.GetVariable().upper()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   473
                if self.ParentWindow.GetDataType(iec_path) is None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   474
                    self.ParentWindow.RemoveDataConsumer(item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   475
                    self.RemoveItem(item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   476
                else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   477
                    self.ParentWindow.AddDataConsumer(iec_path, item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   478
                    item.RefreshVariableType()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   479
            self.ResetVariableNameMask()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   480
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   481
        def ResetData(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   482
            for item in self.Items:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   483
                item.ResetData()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   484
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   485
        def Refresh(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   486
            pass
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   487
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   488
        def OnForceButton(self, event):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   489
            if len(self.Items) == 1:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   490
                wx.CallAfter(self.ForceValue, self.Items[0])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   491
            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   492
                menu = wx.Menu(title='')
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   493
                for item in self.Items:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   494
                    new_id = wx.NewId()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   495
                    AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, 
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   496
                        text=item.GetVariable(self.VariableNameMask))
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   497
                    self.Bind(wx.EVT_MENU, 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   498
                        self.GetForceVariableMenuFunction(item),
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   499
                        id=new_id)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   500
                self.PopupMenu(menu)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   501
            event.Skip()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   502
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   503
        def OnReleaseButton(self, event):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   504
            if len(self.Items) == 1:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   505
                wx.CallAfter(self.ReleaseValue, self.Items[0])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   506
            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   507
                menu = wx.Menu(title='')
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   508
                for item in self.Items:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   509
                    new_id = wx.NewId()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   510
                    AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, 
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   511
                        text=item.GetVariable(self.VariableNameMask))
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   512
                    self.Bind(wx.EVT_MENU, 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   513
                        self.GetReleaseVariableMenuFunction(item),
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   514
                        id=new_id)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   515
                
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   516
                self.PopupMenu(menu)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   517
            event.Skip()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   518
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   519
        def OnDeleteButton(self, event):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   520
            if len(self.Items) == 1:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   521
                wx.CallAfter(self.ParentWindow.DeleteValue, self, self.Items[0])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   522
            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   523
                menu = wx.Menu(title='')
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   524
                for item in self.Items:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   525
                    new_id = wx.NewId()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   526
                    AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, 
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   527
                        text=item.GetVariable(self.VariableNameMask))
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   528
                    self.Bind(wx.EVT_MENU, 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   529
                        self.GetDeleteValueMenuFunction(item),
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   530
                        id=new_id)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   531
                
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   532
                new_id = wx.NewId()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   533
                AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("All"))
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   534
                self.Bind(wx.EVT_MENU, self.OnDeleteAllValuesMenu, id=new_id)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   535
                
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   536
                self.PopupMenu(menu)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   537
            event.Skip()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   538
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   539
        def GetForceVariableMenuFunction(self, item):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   540
            def ForceVariableFunction(event):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   541
                self.ForceValue(item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   542
            return ForceVariableFunction
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   543
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   544
        def GetReleaseVariableMenuFunction(self, item):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   545
            def ReleaseVariableFunction(event):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   546
                self.ReleaseValue(item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   547
            return ReleaseVariableFunction
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   548
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   549
        def GetDeleteValueMenuFunction(self, item):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   550
            def DeleteValueFunction(event):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   551
                self.ParentWindow.DeleteValue(self, item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   552
            return DeleteValueFunction
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   553
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   554
        def ForceValue(self, item):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   555
            iec_path = item.GetVariable().upper()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   556
            iec_type = self.ParentWindow.GetDataType(iec_path)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   557
            if iec_type is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   558
                dialog = ForceVariableDialog(self, iec_type, str(item.GetValue()))
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   559
                if dialog.ShowModal() == wx.ID_OK:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   560
                    self.ParentWindow.ForceDataValue(iec_path, dialog.GetValue())
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   561
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   562
        def ReleaseValue(self, item):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   563
            iec_path = item.GetVariable().upper()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   564
            self.ParentWindow.ReleaseDataValue(iec_path)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   565
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   566
        def OnDeleteAllValuesMenu(self, event):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   567
            wx.CallAfter(self.ParentWindow.DeleteValue, self)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   568
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   569
    class DebugVariableText(DebugVariableViewer):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   570
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   571
        def AddViewer(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   572
            viewer_sizer = wx.FlexGridSizer(cols=2, hgap=0, rows=1, vgap=0)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   573
            viewer_sizer.AddGrowableCol(0)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   574
            self.MainSizer.AddSizer(viewer_sizer, border=5, 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   575
                flag=wx.ALL|wx.GROW|wx.ALIGN_CENTER_VERTICAL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   576
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   577
            variable_name_label = wx.TextCtrl(self, size=wx.Size(0, -1),
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   578
                value=self.Items[0].GetVariable(), style=wx.TE_READONLY|wx.TE_RIGHT|wx.NO_BORDER)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   579
            variable_name_label.SetSelection(variable_name_label.GetLastPosition(), -1)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   580
            viewer_sizer.AddWindow(variable_name_label, flag=wx.GROW)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   581
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   582
            self.ValueLabel = wx.TextCtrl(self,
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   583
                size=wx.Size(100, -1), style=wx.TE_READONLY|wx.TE_RIGHT|wx.NO_BORDER)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   584
            viewer_sizer.AddWindow(self.ValueLabel, 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   585
                border=5, flag=wx.LEFT)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   586
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   587
        def AddButtons(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   588
            button_sizer = wx.BoxSizer(wx.HORIZONTAL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   589
            self.MainSizer.AddSizer(button_sizer, border=5, 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   590
                flag=wx.TOP|wx.BOTTOM|wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   591
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   592
            buttons = [
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   593
                ("ForceButton", "force", _("Force value")),
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   594
                ("ReleaseButton", "release", _("Release value")),
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   595
                ("DeleteButton", "remove_element", _("Remove debug variable"))]
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   596
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   597
            for name, bitmap, help in buttons:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   598
                button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap), 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   599
                      size=wx.Size(28, 28), style=wx.NO_BORDER)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   600
                button.SetToolTipString(help)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   601
                setattr(self, name, button)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   602
                self.Bind(wx.EVT_BUTTON, getattr(self, "On" + name), button)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   603
                button_sizer.AddWindow(button, border=5, flag=wx.LEFT)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   604
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   605
        def Refresh(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   606
            self.ValueLabel.ChangeValue(self.Items[0].GetValue())
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   607
            if self.Items[0].IsForced():
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   608
                self.ValueLabel.SetForegroundColour(wx.BLUE)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   609
            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   610
                self.ValueLabel.SetForegroundColour(wx.BLACK)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   611
            self.ValueLabel.SetSelection(self.ValueLabel.GetLastPosition(), -1)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   612
    
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   613
    def compute_mask(x, y):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   614
        mask = []
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   615
        for xp, yp in zip(x, y):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   616
            if xp == yp:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   617
                mask.append(xp)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   618
            else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   619
                mask.append("*")
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   620
        return mask
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   621
    
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   622
    class DraggingFigureCanvas(FigureCanvas):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   623
        
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   624
        def __init__(self, parent, window, *args, **kwargs):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   625
            FigureCanvas.__init__(self, parent, *args, **kwargs)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   626
            
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   627
            self.ParentWindow = window
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   628
            
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   629
        def draw(self, drawDC=None):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   630
            FigureCanvasAgg.draw(self)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   631
    
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   632
            self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   633
            if self.ParentWindow.IsDragging():
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   634
                destBBox = self.ParentWindow.GetDraggingAxesClippingRegion(self.Parent)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   635
                if destBBox.width > 0 and destBBox.height > 0:
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   636
                    srcPanel = self.ParentWindow.DraggingAxesPanel
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   637
                    srcBBox = srcPanel.GetAxesBoundingBox()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   638
                    
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   639
                    if destBBox.x == 0:
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   640
                        srcX = srcBBox.x + srcBBox.width - destBBox.width
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   641
                    else:
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   642
                        srcX = srcBBox.x
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   643
                    if destBBox.y == 0:
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   644
                        srcY = srcBBox.y + srcBBox.height - destBBox.height
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   645
                    else:
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   646
                        srcY = srcBBox.y
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   647
                    
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   648
                    srcBmp = _convert_agg_to_wx_bitmap(srcPanel.Canvas.get_renderer(), None)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   649
                    srcDC = wx.MemoryDC()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   650
                    srcDC.SelectObject(srcBmp)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   651
                    
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   652
                    destDC = wx.MemoryDC()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   653
                    destDC.SelectObject(self.bitmap)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   654
                    
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   655
                    destDC.BeginDrawing()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   656
                    destDC.Blit(destBBox.x, destBBox.y, 
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   657
                                int(destBBox.width), int(destBBox.height), 
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   658
                                srcDC, srcX, srcY)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   659
                    destDC.EndDrawing()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   660
                    
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   661
            self._isDrawn = True
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   662
            self.gui_repaint(drawDC=drawDC)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   663
    
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   664
    class DebugVariableGraphic(DebugVariableViewer):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   665
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   666
        def __init__(self, parent, window, items, graph_type):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   667
            DebugVariableViewer.__init__(self, parent, window, items)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   668
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   669
            self.GraphType = graph_type
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   670
            self.CursorTick = None
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   671
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   672
            self.ResetGraphics()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   673
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   674
        def AddViewer(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   675
            self.Figure = matplotlib.figure.Figure(facecolor='w')
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   676
            
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   677
            self.Canvas = DraggingFigureCanvas(self, self.ParentWindow, -1, self.Figure)
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   678
            self.Canvas.SetMinSize(wx.Size(200, 200))
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   679
            self.Canvas.SetDropTarget(DebugVariableDropTarget(self.ParentWindow, self))
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   680
            self.Canvas.Bind(wx.EVT_LEFT_DOWN, self.OnCanvasLeftDown)
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   681
            self.Canvas.mpl_connect('motion_notify_event', self.OnCanvasMotion)
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   682
            self.Canvas.mpl_connect('button_release_event', self.OnCanvasLeftUp)
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   683
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   684
            self.MainSizer.AddWindow(self.Canvas, flag=wx.GROW)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   685
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   686
        def AddButtons(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   687
            button_sizer = wx.BoxSizer(wx.VERTICAL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   688
            self.MainSizer.AddSizer(button_sizer, border=5, 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   689
                flag=wx.RIGHT|wx.ALIGN_CENTER_VERTICAL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   690
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   691
            buttons = [
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   692
                ("ForceButton", "force", _("Force value")),
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   693
                ("ReleaseButton", "release", _("Release value")),
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   694
                ("SplitButton", "split", _("Split graphs")),
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   695
                ("DeleteButton", "remove_element", _("Remove debug variable"))]
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   696
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   697
            for name, bitmap, help in buttons:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   698
                button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap), 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   699
                      size=wx.Size(28, 28), style=wx.NO_BORDER)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   700
                button.SetToolTipString(help)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   701
                setattr(self, name, button)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   702
                self.Bind(wx.EVT_BUTTON, getattr(self, "On" + name), button)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   703
                button_sizer.AddWindow(button, border=5, flag=wx.LEFT)
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   704
        
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   705
        def GetAxesBoundingBox(self, absolute=False):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   706
            width, height = self.Canvas.GetSize()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   707
            ax, ay, aw, ah = self.Axes.get_position().bounds
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   708
            bbox = wx.Rect(ax * width, height - (ay + ah) * height - 1,
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   709
                           aw * width + 2, ah * height + 1)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   710
            if absolute:
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   711
                xw, yw = self.GetPosition()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   712
                bbox.x += xw
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   713
                bbox.y += yw
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   714
            return bbox
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   715
        
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   716
        def OnCanvasLeftDown(self, event):
919
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   717
            x, y = event.GetPosition()
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   718
            width, height = self.Canvas.GetSize()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   719
            if len(self.Items) == 1:
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   720
                rect = self.GetAxesBoundingBox()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   721
                if rect.InsideXY(x, y):
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   722
                    xw, yw = self.GetPosition()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   723
                    self.ParentWindow.StartDragNDrop(self, x + xw, y + yw)
919
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   724
                    return
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   725
            elif self.Legend is not None:
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   726
                item_idx = None
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   727
                for i, t in enumerate(self.Legend.get_texts()):
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   728
                    (x0, y0), (x1, y1) = t.get_window_extent().get_points()
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   729
                    rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0)
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   730
                    if rect.InsideXY(x, y):
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   731
                        item_idx = i
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   732
                        break
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   733
                if item_idx is not None:
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   734
                    self.DoDragDrop(item_idx)
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   735
                    return
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   736
            event.Skip()
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   737
        
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   738
        def OnCanvasLeftUp(self, event):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   739
            if self.ParentWindow.IsDragging():
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   740
                width, height = self.Canvas.GetSize()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   741
                xw, yw = self.GetPosition()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   742
                self.ParentWindow.StopDragNDrop(
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   743
                    self.Items[0].GetVariable(),
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   744
                    xw + event.x, 
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   745
                    yw + height - event.y)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   746
        
919
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   747
        def DoDragDrop(self, item_idx):
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   748
            self.ParentWindow.ResetCursorTickRatio()
919
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   749
            data = wx.TextDataObject(str((self.Items[item_idx].GetVariable(), "debug", "move")))
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   750
            dragSource = wx.DropSource(self.Canvas)
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   751
            dragSource.SetData(data)
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   752
            dragSource.DoDragDrop()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   753
        
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   754
        def OnAxesMotion(self, event):
919
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   755
            if self.Is3DCanvas():
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   756
                current_time = gettime()
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   757
                if current_time - self.LastMotionTime > REFRESH_PERIOD:
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   758
                    self.LastMotionTime = current_time
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   759
                    Axes3D._on_move(self.Axes, event)
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   760
        
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   761
        def OnCanvasMotion(self, event):
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   762
            if self.ParentWindow.IsDragging():
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   763
                width, height = self.Canvas.GetSize()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   764
                xw, yw = self.GetPosition()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   765
                self.ParentWindow.MoveDragNDrop(
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   766
                    xw + event.x, 
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   767
                    yw + height - event.y)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   768
            elif not self.Is3DCanvas():
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   769
                if event.inaxes == self.Axes:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   770
                    start_tick, end_tick = self.ParentWindow.GetRange()
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   771
                    cursor_tick_ratio = None
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   772
                    if self.GraphType == GRAPH_ORTHOGONAL:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   773
                        x_data = self.Items[0].GetData(start_tick, end_tick)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   774
                        y_data = self.Items[1].GetData(start_tick, end_tick)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   775
                        if len(x_data) > 0 and len(y_data) > 0:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   776
                            length = min(len(x_data), len(y_data))
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   777
                            d = numpy.sqrt((x_data[:length,1]-event.xdata) ** 2 + (y_data[:length,1]-event.ydata) ** 2)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   778
                            cursor_tick_ratio = float(x_data[numpy.argmin(d), 0] - start_tick) / (end_tick - start_tick)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   779
                    else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   780
                        data = self.Items[0].GetData(start_tick, end_tick)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   781
                        if len(data) > 0:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   782
                            x_min, x_max = self.Axes.get_xlim()
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   783
                            cursor_tick_ratio = float(event.xdata - x_min) / (x_max - x_min)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   784
                    if cursor_tick_ratio is not None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   785
                        self.ParentWindow.SetCursorTickRatio(cursor_tick_ratio)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   786
                else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   787
                    self.ParentWindow.ResetCursorTickRatio()
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   788
        
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   789
        def OnSplitButton(self, event):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   790
            if len(self.Items) == 2 or self.GraphType == GRAPH_ORTHOGONAL:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   791
                wx.CallAfter(self.ParentWindow.SplitGraphs, self)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   792
            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   793
                menu = wx.Menu(title='')
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   794
                for item in self.Items:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   795
                    new_id = wx.NewId()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   796
                    AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, 
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   797
                        text=item.GetVariable(self.VariableNameMask))
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   798
                    self.Bind(wx.EVT_MENU, 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   799
                        self.GetSplitGraphMenuFunction(item),
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   800
                        id=new_id)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   801
                
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   802
                new_id = wx.NewId()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   803
                AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("All"))
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   804
                self.Bind(wx.EVT_MENU, self.OnSplitAllGraphsMenu, id=new_id)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   805
                
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   806
                self.PopupMenu(menu)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   807
            event.Skip()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   808
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   809
        def ResetGraphics(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   810
            self.Figure.clear()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   811
            if self.Is3DCanvas():
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   812
                self.Axes = self.Figure.gca(projection='3d')
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   813
                self.Axes.set_color_cycle(['b'])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   814
                self.LastMotionTime = gettime()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   815
                setattr(self.Axes, "_on_move", self.OnAxesMotion)
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   816
                self.Axes.mouse_init()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   817
            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   818
                self.Axes = self.Figure.gca()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   819
                if self.GraphType == GRAPH_ORTHOGONAL:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   820
                    self.Figure.subplotpars.update(bottom=0.15)
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   821
            self.Axes.set_title('.'.join(self.VariableNameMask))
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   822
            self.Plots = []
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   823
            self.VLine = None
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   824
            self.HLine = None
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   825
            self.TickLabel = None
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   826
            self.SplitButton.Enable(len(self.Items) > 1)
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   827
        
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   828
        def AddItem(self, item):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   829
            DebugVariableViewer.AddItem(self, item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   830
            self.ResetGraphics()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   831
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   832
        def RemoveItem(self, item):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   833
            DebugVariableViewer.RemoveItem(self, item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   834
            if not self.IsEmpty():
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   835
                self.ResetVariableNameMask()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   836
                self.ResetGraphics()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   837
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   838
        def UnregisterObsoleteData(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   839
            DebugVariableViewer.UnregisterObsoleteData(self)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   840
            if not self.IsEmpty():
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   841
                self.ResetVariableNameMask()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   842
                self.ResetGraphics()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   843
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   844
        def Is3DCanvas(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   845
            return self.GraphType == GRAPH_ORTHOGONAL and len(self.Items) == 3
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   846
        
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   847
        def SetCursorTick(self, cursor_tick):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   848
            self.CursorTick = cursor_tick
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   849
            
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   850
        def Refresh(self, refresh_graphics=True):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   851
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   852
            if refresh_graphics:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   853
                start_tick, end_tick = self.ParentWindow.GetRange()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   854
                
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   855
                if self.GraphType == GRAPH_PARALLEL:    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   856
                    min_value = max_value = None
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   857
                    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   858
                    for idx, item in enumerate(self.Items):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   859
                        data = item.GetData(start_tick, end_tick)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   860
                        if data is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   861
                            item_min_value, item_max_value = item.GetRange()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   862
                            if min_value is None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   863
                                min_value = item_min_value
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   864
                            elif item_min_value is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   865
                                min_value = min(min_value, item_min_value)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   866
                            if max_value is None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   867
                                max_value = item_max_value
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   868
                            elif item_max_value is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   869
                                max_value = max(max_value, item_max_value)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   870
                            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   871
                            if len(self.Plots) <= idx:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   872
                                self.Plots.append(
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   873
                                    self.Axes.plot(data[:, 0], data[:, 1])[0])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   874
                            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   875
                                self.Plots[idx].set_data(data[:, 0], data[:, 1])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   876
                        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   877
                    if min_value is not None and max_value is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   878
                        y_center = (min_value + max_value) / 2.
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   879
                        y_range = max(1.0, max_value - min_value)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   880
                    else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   881
                        y_center = 0.5
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   882
                        y_range = 1.0
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   883
                    x_min, x_max = start_tick, end_tick
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   884
                    y_min, y_max = y_center - y_range * 0.55, y_center + y_range * 0.55
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   885
                    
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   886
                    if self.CursorTick is not None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   887
                        if self.VLine is None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   888
                            self.VLine = self.Axes.axvline(self.CursorTick, color='r')
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   889
                        else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   890
                            self.VLine.set_xdata((self.CursorTick, self.CursorTick))
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   891
                        self.VLine.set_visible(True)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   892
                        tick_label = self.ParentWindow.GetTickLabel(self.CursorTick)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   893
                        if self.TickLabel is None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   894
                            self.TickLabel = self.Axes.text(0.5, 0.05, tick_label, 
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   895
                                size = 'small', transform = self.Axes.transAxes)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   896
                        else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   897
                            self.TickLabel.set_text(tick_label)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   898
                    else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   899
                        if self.VLine is not None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   900
                            self.VLine.set_visible(False)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   901
                        if self.TickLabel is not None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   902
                            self.TickLabel.set_text("")
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   903
                else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   904
                    min_start_tick = reduce(max, [item.GetData()[0, 0] 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   905
                                                  for item in self.Items
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   906
                                                  if len(item.GetData()) > 0], 0)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   907
                    start_tick = max(start_tick, min_start_tick)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   908
                    end_tick = max(end_tick, min_start_tick)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   909
                    x_data, x_min, x_max = OrthogonalData(self.Items[0], start_tick, end_tick)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   910
                    y_data, y_min, y_max = OrthogonalData(self.Items[1], start_tick, end_tick)
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   911
                    if self.CursorTick is not None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   912
                        x_cursor, x_forced = self.Items[0].GetValue(self.CursorTick, raw=True)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   913
                        y_cursor, y_forced = self.Items[1].GetValue(self.CursorTick, raw=True)
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   914
                    length = 0
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   915
                    if x_data is not None and y_data is not None:  
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   916
                        length = min(len(x_data), len(y_data))
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   917
                    if len(self.Items) < 3:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   918
                        if x_data is not None and y_data is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   919
                            if len(self.Plots) == 0:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   920
                                self.Plots.append(
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   921
                                    self.Axes.plot(x_data[:, 1][:length], 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   922
                                                   y_data[:, 1][:length])[0])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   923
                            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   924
                                self.Plots[0].set_data(
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   925
                                    x_data[:, 1][:length], 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   926
                                    y_data[:, 1][:length])
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   927
                        
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   928
                        if self.CursorTick is not None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   929
                            if self.VLine is None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   930
                                self.VLine = self.Axes.axvline(x_cursor, color='r')
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   931
                            else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   932
                                self.VLine.set_xdata((x_cursor, x_cursor))
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   933
                            if self.HLine is None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   934
                                self.HLine = self.Axes.axhline(y_cursor, color='r')
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   935
                            else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   936
                                self.HLine.set_ydata((y_cursor, y_cursor))
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   937
                            self.VLine.set_visible(True)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   938
                            self.HLine.set_visible(True)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   939
                            tick_label = self.ParentWindow.GetTickLabel(self.CursorTick)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   940
                            if self.TickLabel is None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   941
                                self.TickLabel = self.Axes.text(0.05, 0.90, tick_label, 
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   942
                                    size = 'small', transform = self.Axes.transAxes)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   943
                            else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   944
                                self.TickLabel.set_text(tick_label)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   945
                        else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   946
                            if self.VLine is not None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   947
                                self.VLine.set_visible(False)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   948
                            if self.HLine is not None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   949
                                self.HLine.set_visible(False)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   950
                            if self.TickLabel is not None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   951
                                self.TickLabel.set_text("")
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   952
                    else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   953
                        while len(self.Axes.lines) > 0:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   954
                            self.Axes.lines.pop()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   955
                        z_data, z_min, z_max = OrthogonalData(self.Items[2], start_tick, end_tick)
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   956
                        if self.CursorTick is not None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   957
                            z_cursor, z_forced = self.Items[2].GetValue(self.CursorTick, raw=True)
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   958
                        if x_data is not None and y_data is not None and z_data is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   959
                            length = min(length, len(z_data))
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   960
                            self.Axes.plot(x_data[:, 1][:length],
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   961
                                           y_data[:, 1][:length],
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   962
                                           zs = z_data[:, 1][:length])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   963
                        self.Axes.set_zlim(z_min, z_max)
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   964
                        if self.CursorTick is not None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   965
                            for kwargs in [{"xs": numpy.array([x_min, x_max])},
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   966
                                           {"ys": numpy.array([y_min, y_max])},
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   967
                                           {"zs": numpy.array([z_min, z_max])}]:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   968
                                for param, value in [("xs", numpy.array([x_cursor, x_cursor])),
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   969
                                                     ("ys", numpy.array([y_cursor, y_cursor])),
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   970
                                                     ("zs", numpy.array([z_cursor, z_cursor]))]:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   971
                                    kwargs.setdefault(param, value)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   972
                                kwargs["color"] = 'r'
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   973
                                self.Axes.plot(**kwargs)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   974
                    
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   975
                self.Axes.set_xlim(x_min, x_max)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   976
                self.Axes.set_ylim(y_min, y_max)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   977
            
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   978
            if self.CursorTick is not None:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   979
                values, forced = apply(zip, [item.GetValue(self.CursorTick) for item in self.Items])
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   980
            else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   981
                values, forced = apply(zip, [(item.GetValue(), item.IsForced()) for item in self.Items])
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   982
            names = [item.GetVariable(self.VariableNameMask) for item in self.Items]
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   983
            labels = map(lambda x: "%s: %s" % x, zip(names, values))
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   984
            colors = map(lambda x: {True: 'b', False: 'k'}[x], forced)
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   985
            if self.GraphType == GRAPH_PARALLEL:
919
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   986
                self.Legend = self.Axes.legend(self.Plots, labels, 
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   987
                    loc="upper left", frameon=False,
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   988
                    prop={'size':'small'})
919
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   989
                for t, color in zip(self.Legend.get_texts(), colors):
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   990
                    t.set_color(color)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   991
            else:
919
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
   992
                self.Legend = None
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   993
                self.Axes.set_xlabel(labels[0], fontdict={'size':'small','color':colors[0]})
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   994
                self.Axes.set_ylabel(labels[1], fontdict={'size':'small','color':colors[1]})
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   995
                if len(labels) > 2:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   996
                    self.Axes.set_zlabel(labels[2], fontdict={'size':'small','color':colors[2]})
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   997
            self.Canvas.draw()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   998
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   999
        def GetSplitGraphMenuFunction(self, item):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1000
            def SplitGraphFunction(event):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1001
                self.ParentWindow.SplitGraphs(self, item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1002
            return SplitGraphFunction
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1003
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1004
        def OnSplitAllGraphsMenu(self, event):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1005
            self.ParentWindow.SplitGraphs(self)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1006
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1007
class DebugVariablePanel(wx.Panel, DebugViewer):
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1008
    
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1009
    def __init__(self, parent, producer, window):
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1010
        wx.Panel.__init__(self, parent, style=wx.SP_3D|wx.TAB_TRAVERSAL)
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1011
        
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1012
        self.ParentWindow = window
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1013
        
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1014
        DebugViewer.__init__(self, producer, True)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1015
        
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1016
        self.HasNewData = False
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
  1017
        
888
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
  1018
        if USE_MPL:
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1019
            main_sizer = wx.BoxSizer(wx.VERTICAL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1020
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1021
            self.Ticks = numpy.array([])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1022
            self.RangeValues = None
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1023
            self.StartTick = 0
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1024
            self.Fixed = False
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1025
            self.Force = False
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1026
            self.CursorTickRatio = None
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1027
            self.DraggingAxesPanel = None
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1028
            self.DraggingAxesBoundingBox = None
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1029
            self.DraggingAxesMousePos = None
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1030
            
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1031
            self.GraphicPanels = []
888
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
  1032
            
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1033
            graphics_button_sizer = wx.BoxSizer(wx.HORIZONTAL)
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1034
            main_sizer.AddSizer(graphics_button_sizer, border=5, flag=wx.GROW|wx.ALL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1035
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1036
            range_label = wx.StaticText(self, label=_('Range:'))
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1037
            graphics_button_sizer.AddWindow(range_label, flag=wx.ALIGN_CENTER_VERTICAL)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1038
            
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1039
            self.CanvasRange = wx.ComboBox(self, style=wx.CB_READONLY)
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1040
            self.Bind(wx.EVT_COMBOBOX, self.OnRangeChanged, self.CanvasRange)
905
eaa1d3a4b52b Fix DebugVariablePanel time range position
Laurent Bessard
parents: 903
diff changeset
  1041
            graphics_button_sizer.AddWindow(self.CanvasRange, 1, 
eaa1d3a4b52b Fix DebugVariablePanel time range position
Laurent Bessard
parents: 903
diff changeset
  1042
                  border=5, flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL)
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1043
            
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1044
            for name, bitmap, help in [
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1045
                ("ResetButton", "reset", _("Clear the graph values")),
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1046
                ("CurrentButton", "current", _("Go to current value")),
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1047
                ("ExportGraphButton", "export_graph", _("Export graph values to clipboard"))]:
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1048
                button = wx.lib.buttons.GenBitmapButton(self, 
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1049
                      bitmap=GetBitmap(bitmap), 
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1050
                      size=wx.Size(28, 28), style=wx.NO_BORDER)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1051
                button.SetToolTipString(help)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1052
                setattr(self, name, button)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1053
                self.Bind(wx.EVT_BUTTON, getattr(self, "On" + name), button)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1054
                graphics_button_sizer.AddWindow(button, border=5, flag=wx.LEFT)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1055
            
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1056
            self.CanvasPosition = wx.ScrollBar(self, 
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1057
                  size=wx.Size(0, 16), style=wx.SB_HORIZONTAL)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1058
            self.CanvasPosition.Bind(wx.EVT_SCROLL_THUMBTRACK, 
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1059
                  self.OnPositionChanging, self.CanvasPosition)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1060
            self.CanvasPosition.Bind(wx.EVT_SCROLL_LINEUP, 
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1061
                  self.OnPositionChanging, self.CanvasPosition)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1062
            self.CanvasPosition.Bind(wx.EVT_SCROLL_LINEDOWN, 
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1063
                  self.OnPositionChanging, self.CanvasPosition)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1064
            self.CanvasPosition.Bind(wx.EVT_SCROLL_PAGEUP, 
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1065
                  self.OnPositionChanging, self.CanvasPosition)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1066
            self.CanvasPosition.Bind(wx.EVT_SCROLL_PAGEDOWN, 
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1067
                  self.OnPositionChanging, self.CanvasPosition)
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1068
            main_sizer.AddWindow(self.CanvasPosition, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1069
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1070
            self.GraphicsWindow = wx.ScrolledWindow(self, style=wx.HSCROLL|wx.VSCROLL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1071
            self.GraphicsWindow.SetDropTarget(DebugVariableDropTarget(self))
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1072
            self.GraphicsWindow.Bind(wx.EVT_SIZE, self.OnGraphicsWindowResize)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1073
            main_sizer.AddWindow(self.GraphicsWindow, 1, flag=wx.GROW)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1074
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1075
            self.GraphicsSizer = wx.BoxSizer(wx.VERTICAL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1076
            self.GraphicsWindow.SetSizer(self.GraphicsSizer)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1077
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1078
            self.RefreshCanvasRange()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1079
            
888
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
  1080
        else:
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1081
            main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1082
            main_sizer.AddGrowableCol(0)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1083
            main_sizer.AddGrowableRow(1)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1084
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1085
            button_sizer = wx.BoxSizer(wx.HORIZONTAL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1086
            main_sizer.AddSizer(button_sizer, border=5, 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1087
                  flag=wx.ALIGN_RIGHT|wx.ALL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1088
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1089
            for name, bitmap, help in [
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1090
                    ("DeleteButton", "remove_element", _("Remove debug variable")),
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1091
                    ("UpButton", "up", _("Move debug variable up")),
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1092
                    ("DownButton", "down", _("Move debug variable down"))]:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1093
                button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap), 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1094
                      size=wx.Size(28, 28), style=wx.NO_BORDER)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1095
                button.SetToolTipString(help)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1096
                setattr(self, name, button)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1097
                button_sizer.AddWindow(button, border=5, flag=wx.LEFT)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1098
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1099
            self.VariablesGrid = CustomGrid(self, size=wx.Size(-1, 150), style=wx.VSCROLL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1100
            self.VariablesGrid.SetDropTarget(DebugVariableDropTarget(self, self.VariablesGrid))
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1101
            self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1102
                  self.OnVariablesGridCellRightClick)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1103
            self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, 
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1104
                  self.OnVariablesGridCellLeftClick)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1105
            main_sizer.AddWindow(self.VariablesGrid, flag=wx.GROW)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1106
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1107
            self.Table = DebugVariableTable(self, [], GetDebugVariablesTableColnames())
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1108
            self.VariablesGrid.SetTable(self.Table)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1109
            self.VariablesGrid.SetButtons({"Delete": self.DeleteButton,
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1110
                                           "Up": self.UpButton,
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1111
                                           "Down": self.DownButton})
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1112
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1113
            def _AddVariable(new_row):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1114
                return self.VariablesGrid.GetGridCursorRow()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1115
            setattr(self.VariablesGrid, "_AddRow", _AddVariable)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1116
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1117
            def _DeleteVariable(row):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1118
                item = self.Table.GetItem(row)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1119
                self.RemoveDataConsumer(item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1120
                self.Table.RemoveItem(row)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1121
                self.RefreshView()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1122
            setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1123
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1124
            def _MoveVariable(row, move):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1125
                new_row = max(0, min(row + move, self.Table.GetNumberRows() - 1))
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1126
                if new_row != row:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1127
                    self.Table.MoveItem(row, new_row)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1128
                    self.RefreshView()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1129
                return new_row
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1130
            setattr(self.VariablesGrid, "_MoveRow", _MoveVariable)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1131
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1132
            self.VariablesGrid.SetRowLabelSize(0)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1133
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1134
            self.GridColSizes = [200, 100]
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1135
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1136
            for col in range(self.Table.GetNumberCols()):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1137
                attr = wx.grid.GridCellAttr()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1138
                attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1139
                self.VariablesGrid.SetColAttr(col, attr)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1140
                self.VariablesGrid.SetColSize(col, self.GridColSizes[col])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1141
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1142
            self.Table.ResetView(self.VariablesGrid)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1143
            self.VariablesGrid.RefreshButtons()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1144
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1145
        self.SetSizer(main_sizer)
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1146
        
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1147
    def SetDataProducer(self, producer):
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1148
        DebugViewer.SetDataProducer(self, producer)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1149
        
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1150
        if USE_MPL:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1151
            if self.DataProducer is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1152
                self.Ticktime = self.DataProducer.GetTicktime()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1153
                self.RefreshCanvasRange()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1154
            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1155
                self.Ticktime = 0
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1156
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1157
    def RefreshNewData(self, *args, **kwargs):
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1158
        if self.HasNewData or self.Force:
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1159
            self.HasNewData = False
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1160
            self.RefreshView(only_values=True)
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1161
        DebugViewer.RefreshNewData(self, *args, **kwargs)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1162
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1163
    def NewDataAvailable(self, tick, *args, **kwargs):
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1164
        if USE_MPL and tick is not None:
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1165
            self.Ticks = numpy.append(self.Ticks, [tick])
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1166
            if not self.Fixed or tick < self.StartTick + self.CurrentRange:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1167
                self.StartTick = max(self.StartTick, tick - self.CurrentRange)
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1168
                self.ResetCursorTick(False)
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1169
        DebugViewer.NewDataAvailable(self, tick, *args, **kwargs)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1170
    
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1171
    def ForceRefresh(self):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1172
        self.Force = True
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1173
        wx.CallAfter(self.NewDataAvailable, None, True)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1174
    
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1175
    def RefreshGraphicsSizer(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1176
        self.GraphicsSizer.Clear()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1177
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1178
        for panel in self.GraphicPanels:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1179
            self.GraphicsSizer.AddWindow(panel, flag=wx.GROW)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1180
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1181
        self.GraphicsSizer.Layout()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1182
        self.RefreshGraphicsWindowScrollbars()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1183
    
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1184
    def SetCursorTickRatio(self, cursor_tick_ratio):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1185
        self.CursorTickRatio = cursor_tick_ratio
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1186
        self.ResetCursorTick() 
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1187
    
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1188
    def ResetCursorTickRatio(self):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1189
        self.CursorTickRatio = None
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1190
        self.ResetCursorTick()
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1191
    
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1192
    def ResetCursorTick(self, force_refresh=True):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1193
        if self.CursorTickRatio is not None and len(self.Ticks) > 0:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1194
            raw_tick = self.StartTick + self.CursorTickRatio * self.CurrentRange
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1195
            cursor_tick = self.Ticks[numpy.argmin(abs(self.Ticks - raw_tick))]
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1196
        else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1197
            cursor_tick = None
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1198
        for panel in self.GraphicPanels:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1199
            if isinstance(panel, DebugVariableGraphic):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1200
                panel.SetCursorTick(cursor_tick)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1201
        if force_refresh:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1202
            self.ForceRefresh()
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1203
    
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1204
    def GetTickLabel(self, tick):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1205
        label = "Tick: %d" % tick
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1206
        if self.Ticktime > 0:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1207
            tick_duration = int(tick * self.Ticktime)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1208
            not_null = False
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1209
            duration = ""
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1210
            for value, format in [(tick_duration / DAY, "%dd"),
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1211
                                  ((tick_duration % DAY) / HOUR, "%dh"),
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1212
                                  ((tick_duration % HOUR) / MINUTE, "%dm"),
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1213
                                  ((tick_duration % MINUTE) / SECOND, "%ds")]:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1214
                
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1215
                if value > 0 or not_null:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1216
                    duration += format % value
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1217
                    not_null = True
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1218
            
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1219
            duration += "%gms" % (float(tick_duration % SECOND) / MILLISECOND) 
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1220
            label += "(%s)" % duration
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1221
        return label
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1222
    
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1223
    def StartDragNDrop(self, panel, x_mouse, y_mouse):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1224
        self.DraggingAxesPanel = panel
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1225
        self.DraggingAxesBoundingBox = panel.GetAxesBoundingBox(absolute=True)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1226
        self.DraggingAxesMousePos = wx.Point(
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1227
            x_mouse - self.DraggingAxesBoundingBox.x, 
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1228
            y_mouse - self.DraggingAxesBoundingBox.y)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1229
        self.ResetCursorTickRatio()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1230
        
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1231
    def MoveDragNDrop(self, x_mouse, y_mouse):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1232
        self.DraggingAxesBoundingBox.x = x_mouse - self.DraggingAxesMousePos.x
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1233
        self.DraggingAxesBoundingBox.y = y_mouse - self.DraggingAxesMousePos.y
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1234
        self.ForceRefresh()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1235
    
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1236
    def IsDragging(self):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1237
        return self.DraggingAxesPanel is not None
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1238
    
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1239
    def GetDraggingAxesClippingRegion(self, panel):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1240
        x, y = panel.GetPosition()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1241
        width, height = panel.Canvas.GetSize()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1242
        bbox = wx.Rect(x, y, width, height)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1243
        bbox = bbox.Intersect(self.DraggingAxesBoundingBox)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1244
        bbox.x -= x
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1245
        bbox.y -= y
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1246
        return bbox
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1247
    
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1248
    def StopDragNDrop(self, variable, x_mouse, y_mouse):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1249
        self.DraggingAxesPanel = None
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1250
        self.DraggingAxesBoundingBox = None
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1251
        self.DraggingAxesMousePos = None
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1252
        for idx, panel in enumerate(self.GraphicPanels):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1253
            xw, yw = panel.GetPosition()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1254
            width, height = panel.Canvas.GetSize()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1255
            bbox = wx.Rect(xw, yw, width, height)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1256
            if bbox.InsideXY(x_mouse, y_mouse):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1257
                merge_type = GRAPH_PARALLEL
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1258
                if panel.Is3DCanvas():
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1259
                    if y_mouse > yw + height / 2:
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1260
                        idx += 1
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1261
                    wx.CallAfter(self.MoveGraph, variable, idx)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1262
                    return
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1263
                else:
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1264
                    rect = panel.GetAxesBoundingBox(True)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1265
                    if rect.InsideXY(x_mouse, y_mouse):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1266
                        merge_rect = wx.Rect(rect.x, rect.y, rect.width / 2., rect.height)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1267
                        if merge_rect.InsideXY(x_mouse, y_mouse):
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1268
                            merge_type = GRAPH_ORTHOGONAL
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1269
                        wx.CallAfter(self.MergeGraphs, variable, idx, merge_type, force=True)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1270
                    else:
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1271
                        if y_mouse > yw + height / 2:
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1272
                            idx += 1
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1273
                        wx.CallAfter(self.MoveGraph, variable, idx)
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1274
                break
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1275
        self.ForceRefresh()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
  1276
    
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1277
    def RefreshView(self, only_values=False):
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1278
        if USE_MPL:
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1279
            self.RefreshCanvasPosition()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1280
            
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1281
            if not self.Fixed or self.Force:
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1282
                self.Force = False
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1283
                refresh_graphics = True
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1284
            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1285
                refresh_graphics = False
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1286
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1287
            for panel in self.GraphicPanels:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1288
                if isinstance(panel, DebugVariableGraphic):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1289
                    panel.Refresh(refresh_graphics)
907
591cb3d96980 Fixed performance issue with matplotlib in DebugVariablePanel and hide 3D graphics when not needed
Laurent Bessard
parents: 905
diff changeset
  1290
                else:
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1291
                    panel.Refresh()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1292
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1293
        else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1294
            self.Freeze()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1295
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1296
            if only_values:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1297
                for col in xrange(self.Table.GetNumberCols()):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1298
                    if self.Table.GetColLabelValue(col, False) == "Value":
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1299
                        for row in xrange(self.Table.GetNumberRows()):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1300
                            self.VariablesGrid.SetCellValue(row, col, str(self.Table.GetValueByName(row, "Value")))
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1301
            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1302
                self.Table.ResetView(self.VariablesGrid)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1303
            self.VariablesGrid.RefreshButtons()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1304
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1305
            self.Thaw()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1306
        
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1307
    def UnregisterObsoleteData(self):
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1308
        if USE_MPL:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1309
            if self.DataProducer is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1310
                self.Ticktime = self.DataProducer.GetTicktime()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1311
                self.RefreshCanvasRange()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1312
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1313
            for panel in self.GraphicPanels:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1314
                panel.UnregisterObsoleteData()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1315
                if panel.IsEmpty():
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1316
                    if panel.Canvas.HasCapture():
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1317
                        panel.Canvas.ReleaseMouse()
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1318
                    self.GraphicPanels.remove(panel)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1319
                    panel.Destroy()
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1320
            
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1321
            self.RefreshGraphicsSizer()
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1322
            self.ForceRefresh()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1323
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1324
        else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1325
            items = [(idx, item) for idx, item in enumerate(self.Table.GetData())]
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1326
            items.reverse()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1327
            for idx, item in items:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1328
                iec_path = item.GetVariable().upper()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1329
                if self.GetDataType(iec_path) is None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1330
                    self.RemoveDataConsumer(item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1331
                    self.Table.RemoveItem(idx)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1332
                else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1333
                    self.AddDataConsumer(iec_path, item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1334
                    item.RefreshVariableType()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1335
            self.Freeze()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1336
            self.Table.ResetView(self.VariablesGrid)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1337
            self.VariablesGrid.RefreshButtons()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1338
            self.Thaw()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1339
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1340
    def ResetView(self):
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1341
        self.DeleteDataConsumers()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1342
        if USE_MPL:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1343
            for panel in self.GraphicPanels:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1344
                panel.Destroy()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1345
            self.GraphicPanels = []
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1346
            self.RefreshGraphicsSizer()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1347
        else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1348
            self.Table.Empty()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1349
            self.Freeze()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1350
            self.Table.ResetView(self.VariablesGrid)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1351
            self.VariablesGrid.RefreshButtons()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1352
            self.Thaw()
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1353
    
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1354
    def RefreshCanvasRange(self):
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1355
        if self.Ticktime == 0 and self.RangeValues != RANGE_VALUES:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1356
            self.RangeValues = RANGE_VALUES
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1357
            self.CanvasRange.Clear()
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1358
            for text, value in RANGE_VALUES:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1359
                self.CanvasRange.Append(text)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1360
            self.CanvasRange.SetStringSelection(RANGE_VALUES[0][0])
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1361
            self.CurrentRange = RANGE_VALUES[0][1]
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1362
            self.RefreshView(True)
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1363
        elif self.Ticktime != 0 and self.RangeValues != TIME_RANGE_VALUES:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1364
            self.RangeValues = TIME_RANGE_VALUES
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1365
            self.CanvasRange.Clear()
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1366
            for text, value in TIME_RANGE_VALUES:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1367
                self.CanvasRange.Append(text)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1368
            self.CanvasRange.SetStringSelection(TIME_RANGE_VALUES[0][0])
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1369
            self.CurrentRange = TIME_RANGE_VALUES[0][1] / self.Ticktime
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1370
            self.RefreshView(True)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1371
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1372
    def RefreshCanvasPosition(self):
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1373
        if len(self.Ticks) > 0:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1374
            pos = int(self.StartTick - self.Ticks[0])
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1375
            range = int(self.Ticks[-1] - self.Ticks[0])
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1376
        else:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1377
            pos = 0
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1378
            range = 0
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1379
        self.CanvasPosition.SetScrollbar(pos, self.CurrentRange, range, self.CurrentRange)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1380
    
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1381
    def GetForceVariableMenuFunction(self, iec_path, item):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1382
        iec_type = self.GetDataType(iec_path)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1383
        def ForceVariableFunction(event):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1384
            if iec_type is not None:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1385
                dialog = ForceVariableDialog(self, iec_type, str(item.GetValue()))
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1386
                if dialog.ShowModal() == wx.ID_OK:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1387
                    self.ForceDataValue(iec_path, dialog.GetValue())
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1388
        return ForceVariableFunction
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1389
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1390
    def GetReleaseVariableMenuFunction(self, iec_path):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1391
        def ReleaseVariableFunction(event):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1392
            self.ReleaseDataValue(iec_path)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1393
        return ReleaseVariableFunction
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1394
    
892
771581a6b0be Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents: 888
diff changeset
  1395
    def OnVariablesGridCellLeftClick(self, event):
771581a6b0be Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents: 888
diff changeset
  1396
        if event.GetCol() == 0:
771581a6b0be Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents: 888
diff changeset
  1397
            row = event.GetRow()
898
6b2958f04f30 Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents: 895
diff changeset
  1398
            data = wx.TextDataObject(str((self.Table.GetValueByName(row, "Variable"), "debug")))
892
771581a6b0be Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents: 888
diff changeset
  1399
            dragSource = wx.DropSource(self.VariablesGrid)
771581a6b0be Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents: 888
diff changeset
  1400
            dragSource.SetData(data)
771581a6b0be Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents: 888
diff changeset
  1401
            dragSource.DoDragDrop()
771581a6b0be Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents: 888
diff changeset
  1402
        event.Skip()
771581a6b0be Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents: 888
diff changeset
  1403
    
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1404
    def OnVariablesGridCellRightClick(self, event):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1405
        row, col = event.GetRow(), event.GetCol()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1406
        if self.Table.GetColLabelValue(col, False) == "Value":
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1407
            iec_path = self.Table.GetValueByName(row, "Variable").upper()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1408
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1409
            menu = wx.Menu(title='')
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1410
            
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1411
            new_id = wx.NewId()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1412
            AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Force value"))
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1413
            self.Bind(wx.EVT_MENU, self.GetForceVariableMenuFunction(iec_path.upper(), self.Table.GetItem(row)), id=new_id)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1414
            
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1415
            new_id = wx.NewId()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1416
            AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Release value"))
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1417
            self.Bind(wx.EVT_MENU, self.GetReleaseVariableMenuFunction(iec_path.upper()), id=new_id)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1418
            
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1419
            if self.Table.IsForced(row):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1420
                menu.Enable(new_id, True)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1421
            else:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1422
                menu.Enable(new_id, False)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1423
            
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1424
            self.PopupMenu(menu)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1425
            
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1426
            menu.Destroy()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1427
        event.Skip()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1428
    
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1429
    def RefreshRange(self):
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1430
        if len(self.Ticks) > 0:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1431
            if self.Fixed and self.Ticks[-1] - self.Ticks[0] < self.CurrentRange:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1432
                self.Fixed = False
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1433
            if self.Fixed:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1434
                self.StartTick = min(self.StartTick, self.Ticks[-1] - self.CurrentRange)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1435
            else:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1436
                self.StartTick = max(self.Ticks[0], self.Ticks[-1] - self.CurrentRange)
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1437
        self.ForceRefresh()
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1438
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1439
    def OnRangeChanged(self, event):
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1440
        try:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1441
            if self.Ticktime == 0:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1442
                self.CurrentRange = self.RangeValues[self.CanvasRange.GetSelection()][1]
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1443
            else:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1444
                self.CurrentRange = self.RangeValues[self.CanvasRange.GetSelection()][1] / self.Ticktime
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1445
        except ValueError, e:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1446
            self.CanvasRange.SetValue(str(self.CurrentRange))
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1447
        wx.CallAfter(self.RefreshRange)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1448
        event.Skip()
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1449
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1450
    def OnResetButton(self, event):
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1451
        self.StartTick = 0
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1452
        self.Fixed = False
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1453
        for panel in self.GraphicPanels:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1454
            panel.ResetData()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1455
        self.ForceRefresh()
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1456
        event.Skip()
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1457
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1458
    def OnCurrentButton(self, event):
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1459
        if len(self.Ticks) > 0:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1460
            self.StartTick = max(self.Ticks[0], self.Ticks[-1] - self.CurrentRange)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1461
            self.Fixed = False
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1462
            self.ForceRefresh()
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1463
        event.Skip()
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1464
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1465
    def CopyDataToClipboard(self, variables):
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1466
        text = "tick;%s;\n" % ";".join([item.GetVariable() for item, data in variables])
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1467
        next_tick = NextTick(variables)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1468
        while next_tick is not None:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1469
            values = []
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1470
            for item, data in variables:
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1471
                if len(data) > 0:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1472
                    if next_tick == data[0][0]:
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1473
                        var_type = item.GetVariableType()
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1474
                        if var_type in ["STRING", "WSTRING"]:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1475
                            value = item.GetRawValue(int(data.pop(0)[2]))
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1476
                            if var_type == "STRING":
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1477
                                values.append("'%s'" % value)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1478
                            else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1479
                                values.append('"%s"' % value)
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1480
                        else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1481
                            values.append("%.3f" % data.pop(0)[1])
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1482
                    else:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1483
                        values.append("")
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1484
                else:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1485
                    values.append("")
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1486
            text += "%d;%s;\n" % (next_tick, ";".join(values))
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1487
            next_tick = NextTick(variables)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1488
        self.ParentWindow.SetCopyBuffer(text)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1489
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1490
    def OnExportGraphButton(self, event):
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1491
        variables = []
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1492
        if USE_MPL:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1493
            items = []
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1494
            for panel in self.GraphicPanels:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1495
                items.extend(panel.GetItems())
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1496
        else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1497
            items = self.Table.GetData()
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1498
        for item in items:
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1499
            if item.IsNumVariable():
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1500
                variables.append((item, [entry for entry in item.GetData()]))
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1501
        wx.CallAfter(self.CopyDataToClipboard, variables)
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1502
        event.Skip()
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1503
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1504
    def OnPositionChanging(self, event):
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1505
        if len(self.Ticks) > 0:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1506
            self.StartTick = self.Ticks[0] + event.GetPosition()
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1507
            self.Fixed = True
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1508
            self.ForceRefresh()
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1509
        event.Skip()
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
  1510
    
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1511
    def GetRange(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1512
        return self.StartTick, self.StartTick + self.CurrentRange
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1513
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1514
    def GetViewerIndex(self, viewer):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1515
        if viewer in self.GraphicPanels:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1516
            return self.GraphicPanels.index(viewer)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1517
        return None
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1518
    
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1519
    def InsertValue(self, iec_path, idx = None, force=False):
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1520
        if USE_MPL:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1521
            for panel in self.GraphicPanels:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1522
                if panel.GetItem(iec_path) is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1523
                    return
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1524
            if idx is None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1525
                idx = len(self.GraphicPanels)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1526
        else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1527
            for item in self.Table.GetData():
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1528
                if iec_path == item.GetVariable():
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1529
                    return
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1530
            if idx is None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1531
                idx = self.Table.GetNumberRows()
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
  1532
        item = VariableTableItem(self, iec_path)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1533
        result = self.AddDataConsumer(iec_path.upper(), item)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1534
        if result is not None or force:
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1535
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1536
            if USE_MPL:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1537
                if item.IsNumVariable():
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1538
                    panel = DebugVariableGraphic(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1539
                else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1540
                    panel = DebugVariableText(self.GraphicsWindow, self, [item])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1541
                if idx is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1542
                    self.GraphicPanels.insert(idx, panel)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1543
                else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1544
                    self.GraphicPanels.append(panel)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1545
                self.RefreshGraphicsSizer()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1546
            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1547
                self.Table.InsertItem(idx, item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1548
            
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1549
            self.ForceRefresh()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1550
    
919
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1551
    def MoveGraph(self, iec_path, idx = None):
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1552
        if idx is None:
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1553
            idx = len(self.GraphicPanels)
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1554
        source_panel = None
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1555
        item = None
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1556
        for panel in self.GraphicPanels:
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1557
            item = panel.GetItem(iec_path)
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1558
            if item is not None:
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1559
                source_panel = panel
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1560
                break
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1561
        if source_panel is not None:
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1562
            source_panel.RemoveItem(item)
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1563
            if source_panel.IsEmpty():
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1564
                if source_panel.Canvas.HasCapture():
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1565
                    source_panel.Canvas.ReleaseMouse()
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1566
                self.GraphicPanels.remove(source_panel)
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1567
                source_panel.Destroy()
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1568
            
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1569
            panel = DebugVariableGraphic(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1570
            self.GraphicPanels.insert(idx, panel)
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1571
            self.RefreshGraphicsSizer()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1572
            self.ForceRefresh()
919
4a36e38e51d3 Fix bug in DebugVariablePanel when manipulating graph layout and adding drag'n drop graph from parallel graphs and moving graphs order
Laurent Bessard
parents: 916
diff changeset
  1573
    
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1574
    def SplitGraphs(self, source_panel, item=None):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1575
        source_idx = self.GetViewerIndex(source_panel)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1576
        if source_idx is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1577
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1578
            if item is None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1579
                source_items = source_panel.GetItems()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1580
                while len(source_items) > 1:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1581
                    item = source_items.pop(-1)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1582
                    if item.IsNumVariable():
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1583
                        panel = DebugVariableGraphic(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1584
                    else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1585
                        panel = DebugVariableText(self.GraphicsWindow, self, [item])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1586
                    self.GraphicPanels.insert(source_idx + 1, panel)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1587
                if isinstance(source_panel, DebugVariableGraphic):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1588
                    source_panel.GraphType = GRAPH_PARALLEL
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1589
                    source_panel.ResetGraphics()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1590
                    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1591
            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1592
                source_panel.RemoveItem(item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1593
                if item.IsNumVariable():
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1594
                    panel = DebugVariableGraphic(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1595
                else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1596
                    panel = DebugVariableText(self.GraphicsWindow, self, [item])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1597
                self.GraphicPanels.insert(source_idx + 1, panel)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1598
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1599
            self.RefreshGraphicsSizer()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1600
            self.ForceRefresh()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1601
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1602
    def MergeGraphs(self, source, target_idx, merge_type, force=False):
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1603
        source_item = None
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1604
        source_panel = None
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1605
        for panel in self.GraphicPanels:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1606
            source_item = panel.GetItem(source)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1607
            if source_item is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1608
                source_panel = panel
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1609
                break
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1610
        if source_item is None:
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1611
            item = VariableTableItem(self, source)
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1612
            if item.IsNumVariable():
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1613
                result = self.AddDataConsumer(source.upper(), item)
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1614
                if result is not None or force:
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1615
                    source_item = item
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1616
        if source_item is not None:
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1617
            target_panel = self.GraphicPanels[target_idx]
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1618
            graph_type = target_panel.GraphType
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1619
            if target_panel != source_panel:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1620
                if (merge_type == GRAPH_PARALLEL and graph_type != merge_type or
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1621
                    merge_type == GRAPH_ORTHOGONAL and 
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1622
                    (graph_type == GRAPH_PARALLEL and len(target_panel.Items) > 1 or
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1623
                     graph_type == GRAPH_ORTHOGONAL and len(target_panel.Items) >= 3)):
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1624
                    return
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1625
                
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1626
                if source_panel is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1627
                    source_panel.RemoveItem(source_item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1628
                    if source_panel.IsEmpty():
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1629
                        if source_panel.Canvas.HasCapture():
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1630
                            source_panel.Canvas.ReleaseMouse()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1631
                        self.GraphicPanels.remove(source_panel)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1632
                        source_panel.Destroy()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1633
                        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1634
                target_panel.AddItem(source_item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1635
                target_panel.GraphType = merge_type
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1636
                target_panel.ResetGraphics()
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
  1637
                
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1638
                self.RefreshGraphicsSizer()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1639
                self.ForceRefresh()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1640
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1641
    def DeleteValue(self, source_panel, item=None):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1642
        source_idx = self.GetViewerIndex(source_panel)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1643
        if source_idx is not None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1644
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1645
            if item is None:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1646
                source_panel.Clear()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1647
                source_panel.Destroy()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1648
                self.GraphicPanels.remove(source_panel)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1649
                self.RefreshGraphicsSizer()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1650
            else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1651
                source_panel.RemoveItem(item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1652
                if source_panel.IsEmpty():
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1653
                    source_panel.Destroy()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1654
                    self.GraphicPanels.remove(source_panel)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1655
                    self.RefreshGraphicsSizer()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1656
            self.ForceRefresh()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1657
    
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
  1658
    def GetDebugVariables(self):
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1659
        if USE_MPL:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1660
            return [panel.GetVariables() for panel in self.GraphicPanels]
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1661
        else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1662
            return [item.GetVariable() for item in self.Table.GetData()]
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1663
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1664
    def SetDebugVariables(self, variables):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1665
        if USE_MPL:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1666
            for variable in variables:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1667
                if isinstance(variable, (TupleType, ListType)):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1668
                    items = []
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1669
                    for iec_path in variable:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1670
                        item = VariableTableItem(self, iec_path)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1671
                        if not item.IsNumVariable():
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1672
                            continue
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1673
                        self.AddDataConsumer(iec_path.upper(), item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1674
                        items.append(item)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1675
                    if isinstance(variable, ListType):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1676
                        panel = DebugVariableGraphic(self.GraphicsWindow, self, items, GRAPH_PARALLEL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1677
                    elif isinstance(variable, TupleType) and len(items) <= 3:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1678
                        panel = DebugVariableGraphic(self.GraphicsWindow, self, items, GRAPH_ORTHOGONAL)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1679
                    else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1680
                        continue
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1681
                    self.GraphicPanels.append(panel)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1682
                    self.RefreshGraphicsSizer()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1683
                else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1684
                    self.InsertValue(variable, force=True)
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1685
            self.ForceRefresh()
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1686
        else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1687
            for variable in variables:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1688
                if isinstance(variable, (ListType, TupleType)):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1689
                    for iec_path in variable:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1690
                        self.InsertValue(iec_path, force=True)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1691
                else:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1692
                    self.InsertValue(variable, force=True)
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
  1693
    
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
  1694
    def ResetGraphicsValues(self):
888
baf5dbfd28f4 Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents: 887
diff changeset
  1695
        if USE_MPL:
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1696
            self.Ticks = numpy.array([])
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1697
            self.StartTick = 0
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1698
            for panel in self.GraphicPanels:
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1699
                panel.ResetData()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1700
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1701
    def RefreshGraphicsWindowScrollbars(self):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1702
        xstart, ystart = self.GraphicsWindow.GetViewStart()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1703
        window_size = self.GraphicsWindow.GetClientSize()
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1704
        vwidth, vheight = self.GraphicsSizer.GetMinSize()
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
  1705
        posx = max(0, min(xstart, (vwidth - window_size[0]) / SCROLLBAR_UNIT))
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
  1706
        posy = max(0, min(ystart, (vheight - window_size[1]) / SCROLLBAR_UNIT))
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1707
        self.GraphicsWindow.Scroll(posx, posy)
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1708
        self.GraphicsWindow.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, 
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
  1709
                vwidth / SCROLLBAR_UNIT, vheight / SCROLLBAR_UNIT, posx, posy)
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
  1710
    
916
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1711
    def OnGraphicsWindowResize(self, event):
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
  1712
        self.RefreshGraphicsWindowScrollbars()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
  1713
        event.Skip()