controls/DebugVariablePanel/DebugVariableGraphicPanel.py
author Laurent Bessard
Fri, 31 May 2013 18:32:51 +0200
changeset 1207 fb9799a0c0f7
parent 1202 3d8c87ab2b5d
child 1209 953a8f14040a
permissions -rw-r--r--
Rewrite DebugVariableTablePanel
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
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    25
from types import TupleType
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
    26
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
    27
import numpy
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    28
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    29
import wx
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    30
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
    31
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    32
import matplotlib
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    33
matplotlib.use('WX')
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    34
import matplotlib.pyplot
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    35
from matplotlib.backends.backend_wxagg import _convert_agg_to_wx_bitmap
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    36
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    37
from editors.DebugViewer import DebugViewer
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    38
from util.BitmapLibrary import GetBitmap
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    39
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    40
from DebugVariableItem import DebugVariableItem
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    41
from DebugVariableTextViewer import DebugVariableTextViewer
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    42
from DebugVariableGraphicViewer import *
1199
fc0e7d80494f Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents: 1198
diff changeset
    43
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    44
class DebugVariableDropTarget(wx.TextDropTarget):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    45
    
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    46
    def __init__(self, parent):
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    47
        wx.TextDropTarget.__init__(self)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    48
        self.ParentWindow = parent
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    49
    
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
    50
    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
    51
        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
    52
    
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
    53
    def OnDragOver(self, x, y, d):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    54
        self.ParentControl.OnMouseDragging(x, y)
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    55
        self.ParentWindow.RefreshHighlight(x, y)
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
    56
        return wx.TextDropTarget.OnDragOver(self, x, y, d)
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
    57
        
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    58
    def OnDropText(self, x, y, data):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    59
        message = None
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    60
        try:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    61
            values = eval(data)
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    62
            if not isinstance(values, TupleType):
1207
fb9799a0c0f7 Rewrite DebugVariableTablePanel
Laurent Bessard
parents: 1202
diff changeset
    63
                raise ValueError
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    64
        except:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    65
            message = _("Invalid value \"%s\" for debug variable")%data
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    66
            values = None
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    67
            
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    68
        if message is not None:
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    69
            wx.CallAfter(self.ShowMessage, message)
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    70
        
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    71
        elif values[1] == "debug":
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
    72
            if len(values) > 2 and values[2] == "move":
945
c1159acb0886 Added support for drag'n dropping non-numeric variables
Laurent Bessard
parents: 943
diff changeset
    73
                self.ParentWindow.MoveValue(values[0])
c1159acb0886 Added support for drag'n dropping non-numeric variables
Laurent Bessard
parents: 943
diff changeset
    74
            else:
c1159acb0886 Added support for drag'n dropping non-numeric variables
Laurent Bessard
parents: 943
diff changeset
    75
                self.ParentWindow.InsertValue(values[0], force=True)
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
    76
    
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
    77
    def OnLeave(self):
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    78
        self.ParentWindow.ResetHighlight()
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
    79
        return wx.TextDropTarget.OnLeave(self)
934
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
    80
    
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    81
    def ShowMessage(self, message):
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    82
        dialog = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    83
        dialog.ShowModal()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    84
        dialog.Destroy()
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
    85
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    86
MILLISECOND = 1000000
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    87
SECOND = 1000 * MILLISECOND
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    88
MINUTE = 60 * SECOND
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    89
HOUR = 60 * MINUTE
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    90
DAY = 24 * HOUR
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    91
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    92
ZOOM_VALUES = map(lambda x:("x %.1f" % x, x), [math.sqrt(2) ** i for i in xrange(8)])
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    93
RANGE_VALUES = \
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    94
    [("%dms" % i, i * MILLISECOND) for i in (10, 20, 50, 100, 200, 500)] + \
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    95
    [("%ds" % i, i * SECOND) for i in (1, 2, 5, 10, 20, 30)] + \
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    96
    [("%dm" % i, i * MINUTE) for i in (1, 2, 5, 10, 20, 30)] + \
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    97
    [("%dh" % i, i * HOUR) for i in (1, 2, 3, 6, 12, 24)]
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    98
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
    99
SCROLLBAR_UNIT = 10
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   100
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   101
def compute_mask(x, y):
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   102
    mask = []
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   103
    for xp, yp in zip(x, y):
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   104
        if xp == yp:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   105
            mask.append(xp)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   106
        else:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   107
            mask.append("*")
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   108
    return mask
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   109
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   110
def NextTick(variables):
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   111
    next_tick = None
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   112
    for item, data in variables:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   113
        if len(data) > 0:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   114
            if next_tick is None:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   115
                next_tick = data[0][0]
945
c1159acb0886 Added support for drag'n dropping non-numeric variables
Laurent Bessard
parents: 943
diff changeset
   116
            else:
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   117
                next_tick = min(next_tick, data[0][0])
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   118
    return next_tick
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   119
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   120
class DebugVariableGraphicPanel(wx.Panel, DebugViewer):
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   121
    
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   122
    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
   123
        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
   124
        
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   125
        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
   126
        
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   127
        self.HasNewData = False
1008
1e5d285864f6 Fixed bugs in DebugVariablePanel when matplotlib not installed
Laurent Bessard
parents: 988
diff changeset
   128
        self.Force = False
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   129
        
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   130
        self.SetBackgroundColour(wx.WHITE)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   131
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   132
        main_sizer = wx.BoxSizer(wx.VERTICAL)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   133
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   134
        self.Ticks = numpy.array([])
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   135
        self.StartTick = 0
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   136
        self.Fixed = False
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   137
        self.CursorTick = None
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   138
        self.DraggingAxesPanel = None
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   139
        self.DraggingAxesBoundingBox = None
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   140
        self.DraggingAxesMousePos = None
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   141
        self.VetoScrollEvent = False
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   142
        self.VariableNameMask = []
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   143
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   144
        self.GraphicPanels = []
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   145
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   146
        graphics_button_sizer = wx.BoxSizer(wx.HORIZONTAL)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   147
        main_sizer.AddSizer(graphics_button_sizer, border=5, flag=wx.GROW|wx.ALL)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   148
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   149
        range_label = wx.StaticText(self, label=_('Range:'))
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   150
        graphics_button_sizer.AddWindow(range_label, flag=wx.ALIGN_CENTER_VERTICAL)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   151
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   152
        self.CanvasRange = wx.ComboBox(self, style=wx.CB_READONLY)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   153
        self.Bind(wx.EVT_COMBOBOX, self.OnRangeChanged, self.CanvasRange)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   154
        graphics_button_sizer.AddWindow(self.CanvasRange, 1, 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   155
              border=5, flag=wx.LEFT|wx.ALIGN_CENTER_VERTICAL)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   156
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   157
        self.CanvasRange.Clear()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   158
        default_range_idx = 0
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   159
        for idx, (text, value) in enumerate(RANGE_VALUES):
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   160
            self.CanvasRange.Append(text)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   161
            if text == "1s":
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   162
                default_range_idx = idx
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   163
        self.CanvasRange.SetSelection(default_range_idx)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   164
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   165
        for name, bitmap, help in [
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   166
            ("CurrentButton", "current", _("Go to current value")),
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   167
            ("ExportGraphButton", "export_graph", _("Export graph values to clipboard"))]:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   168
            button = wx.lib.buttons.GenBitmapButton(self, 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   169
                  bitmap=GetBitmap(bitmap), 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   170
                  size=wx.Size(28, 28), style=wx.NO_BORDER)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   171
            button.SetToolTipString(help)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   172
            setattr(self, name, button)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   173
            self.Bind(wx.EVT_BUTTON, getattr(self, "On" + name), button)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   174
            graphics_button_sizer.AddWindow(button, border=5, flag=wx.LEFT)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   175
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   176
        self.CanvasPosition = wx.ScrollBar(self, 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   177
              size=wx.Size(0, 16), style=wx.SB_HORIZONTAL)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   178
        self.CanvasPosition.Bind(wx.EVT_SCROLL_THUMBTRACK, 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   179
              self.OnPositionChanging, self.CanvasPosition)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   180
        self.CanvasPosition.Bind(wx.EVT_SCROLL_LINEUP, 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   181
              self.OnPositionChanging, self.CanvasPosition)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   182
        self.CanvasPosition.Bind(wx.EVT_SCROLL_LINEDOWN, 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   183
              self.OnPositionChanging, self.CanvasPosition)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   184
        self.CanvasPosition.Bind(wx.EVT_SCROLL_PAGEUP, 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   185
              self.OnPositionChanging, self.CanvasPosition)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   186
        self.CanvasPosition.Bind(wx.EVT_SCROLL_PAGEDOWN, 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   187
              self.OnPositionChanging, self.CanvasPosition)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   188
        main_sizer.AddWindow(self.CanvasPosition, border=5, flag=wx.GROW|wx.LEFT|wx.RIGHT|wx.BOTTOM)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   189
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   190
        self.TickSizer = wx.BoxSizer(wx.HORIZONTAL)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   191
        main_sizer.AddSizer(self.TickSizer, border=5, flag=wx.ALL|wx.GROW)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   192
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   193
        self.TickLabel = wx.StaticText(self)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   194
        self.TickSizer.AddWindow(self.TickLabel, border=5, flag=wx.RIGHT)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   195
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   196
        self.MaskLabel = wx.TextCtrl(self, style=wx.TE_READONLY|wx.TE_CENTER|wx.NO_BORDER)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   197
        self.TickSizer.AddWindow(self.MaskLabel, 1, border=5, flag=wx.RIGHT|wx.GROW)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   198
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   199
        self.TickTimeLabel = wx.StaticText(self)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   200
        self.TickSizer.AddWindow(self.TickTimeLabel)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   201
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   202
        self.GraphicsWindow = wx.ScrolledWindow(self, style=wx.HSCROLL|wx.VSCROLL)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   203
        self.GraphicsWindow.SetBackgroundColour(wx.WHITE)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   204
        self.GraphicsWindow.SetDropTarget(DebugVariableDropTarget(self))
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   205
        self.GraphicsWindow.Bind(wx.EVT_ERASE_BACKGROUND, self.OnGraphicsWindowEraseBackground)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   206
        self.GraphicsWindow.Bind(wx.EVT_PAINT, self.OnGraphicsWindowPaint)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   207
        self.GraphicsWindow.Bind(wx.EVT_SIZE, self.OnGraphicsWindowResize)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   208
        self.GraphicsWindow.Bind(wx.EVT_MOUSEWHEEL, self.OnGraphicsWindowMouseWheel)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   209
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   210
        main_sizer.AddWindow(self.GraphicsWindow, 1, flag=wx.GROW)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   211
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   212
        self.GraphicsSizer = wx.BoxSizer(wx.VERTICAL)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   213
        self.GraphicsWindow.SetSizer(self.GraphicsSizer)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   214
    
1192
d8783c0c7d80 Fixed bugs in DebugVariablePanel with ticktime modifications
Laurent Bessard
parents: 1191
diff changeset
   215
        DebugViewer.__init__(self, producer, True)
d8783c0c7d80 Fixed bugs in DebugVariablePanel with ticktime modifications
Laurent Bessard
parents: 1191
diff changeset
   216
        
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
   217
        self.SetSizer(main_sizer)
1192
d8783c0c7d80 Fixed bugs in DebugVariablePanel with ticktime modifications
Laurent Bessard
parents: 1191
diff changeset
   218
    
d8783c0c7d80 Fixed bugs in DebugVariablePanel with ticktime modifications
Laurent Bessard
parents: 1191
diff changeset
   219
    def SetTickTime(self, ticktime=0):
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   220
        self.Ticktime = ticktime
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   221
        if self.Ticktime == 0:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   222
            self.Ticktime = MILLISECOND
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   223
        self.CurrentRange = RANGE_VALUES[
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   224
            self.CanvasRange.GetSelection()][1] / self.Ticktime
1192
d8783c0c7d80 Fixed bugs in DebugVariablePanel with ticktime modifications
Laurent Bessard
parents: 1191
diff changeset
   225
    
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   226
    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
   227
        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
   228
        
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   229
        if self.DataProducer is not None:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   230
            self.SetTickTime(self.DataProducer.GetTicktime())
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   231
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   232
    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
   233
        if self.HasNewData or self.Force:
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   234
            self.HasNewData = False
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   235
            self.RefreshView()
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   236
        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
   237
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   238
    def NewDataAvailable(self, tick, *args, **kwargs):
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   239
        if tick is not None:
927
bd3e5b65e8be Fix bug when resetting graphs values
Laurent Bessard
parents: 925
diff changeset
   240
            if len(self.Ticks) == 0:
bd3e5b65e8be Fix bug when resetting graphs values
Laurent Bessard
parents: 925
diff changeset
   241
                self.StartTick = tick 
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   242
            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
   243
            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
   244
                self.StartTick = max(self.StartTick, tick - self.CurrentRange)
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   245
            if self.Fixed and self.Ticks[-1] - self.Ticks[0] < self.CurrentRange:
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   246
                self.Force = True
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   247
        DebugViewer.NewDataAvailable(self, tick, *args, **kwargs)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   248
    
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   249
    def ForceRefresh(self):
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   250
        self.Force = True
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   251
        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
   252
    
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
   253
    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
   254
        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
   255
        
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   256
        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
   257
            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
   258
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   259
        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
   260
        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
   261
    
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   262
    def SetCanvasPosition(self, tick):
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   263
        tick = max(self.Ticks[0], min(tick, self.Ticks[-1] - self.CurrentRange))
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   264
        self.StartTick = self.Ticks[numpy.argmin(numpy.abs(self.Ticks - tick))]
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   265
        self.Fixed = True
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   266
        self.RefreshCanvasPosition()
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   267
        self.ForceRefresh()
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   268
    
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   269
    def SetCursorTick(self, cursor_tick):
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   270
        self.CursorTick = cursor_tick
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   271
        self.Fixed = True
1084
baa09a1c7b15 Fixed bug in DebugVariablePanel, cursor not reset when graphs were reset
Laurent Bessard
parents: 1044
diff changeset
   272
        self.UpdateCursorTick() 
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   273
    
1174
9cc1a3fa9619 Add support for moving cursor in Debug Graphs using arrow keys
Laurent Bessard
parents: 1102
diff changeset
   274
    def MoveCursorTick(self, move):
9cc1a3fa9619 Add support for moving cursor in Debug Graphs using arrow keys
Laurent Bessard
parents: 1102
diff changeset
   275
        if self.CursorTick is not None:
9cc1a3fa9619 Add support for moving cursor in Debug Graphs using arrow keys
Laurent Bessard
parents: 1102
diff changeset
   276
            cursor_tick = max(self.Ticks[0], 
9cc1a3fa9619 Add support for moving cursor in Debug Graphs using arrow keys
Laurent Bessard
parents: 1102
diff changeset
   277
                          min(self.CursorTick + move, 
9cc1a3fa9619 Add support for moving cursor in Debug Graphs using arrow keys
Laurent Bessard
parents: 1102
diff changeset
   278
                              self.Ticks[-1]))
1192
d8783c0c7d80 Fixed bugs in DebugVariablePanel with ticktime modifications
Laurent Bessard
parents: 1191
diff changeset
   279
            cursor_tick_idx = numpy.argmin(numpy.abs(self.Ticks - cursor_tick))
d8783c0c7d80 Fixed bugs in DebugVariablePanel with ticktime modifications
Laurent Bessard
parents: 1191
diff changeset
   280
            if self.Ticks[cursor_tick_idx] == self.CursorTick:
d8783c0c7d80 Fixed bugs in DebugVariablePanel with ticktime modifications
Laurent Bessard
parents: 1191
diff changeset
   281
                cursor_tick_idx = max(0, 
d8783c0c7d80 Fixed bugs in DebugVariablePanel with ticktime modifications
Laurent Bessard
parents: 1191
diff changeset
   282
                                  min(cursor_tick_idx + abs(move) / move, 
d8783c0c7d80 Fixed bugs in DebugVariablePanel with ticktime modifications
Laurent Bessard
parents: 1191
diff changeset
   283
                                      len(self.Ticks) - 1))
d8783c0c7d80 Fixed bugs in DebugVariablePanel with ticktime modifications
Laurent Bessard
parents: 1191
diff changeset
   284
            self.CursorTick = self.Ticks[cursor_tick_idx]
1174
9cc1a3fa9619 Add support for moving cursor in Debug Graphs using arrow keys
Laurent Bessard
parents: 1102
diff changeset
   285
            self.StartTick = max(self.Ticks[
9cc1a3fa9619 Add support for moving cursor in Debug Graphs using arrow keys
Laurent Bessard
parents: 1102
diff changeset
   286
                                numpy.argmin(numpy.abs(self.Ticks - 
9cc1a3fa9619 Add support for moving cursor in Debug Graphs using arrow keys
Laurent Bessard
parents: 1102
diff changeset
   287
                                        self.CursorTick + self.CurrentRange))],
9cc1a3fa9619 Add support for moving cursor in Debug Graphs using arrow keys
Laurent Bessard
parents: 1102
diff changeset
   288
                             min(self.StartTick, self.CursorTick))
9cc1a3fa9619 Add support for moving cursor in Debug Graphs using arrow keys
Laurent Bessard
parents: 1102
diff changeset
   289
            self.RefreshCanvasPosition()
9cc1a3fa9619 Add support for moving cursor in Debug Graphs using arrow keys
Laurent Bessard
parents: 1102
diff changeset
   290
            self.UpdateCursorTick() 
9cc1a3fa9619 Add support for moving cursor in Debug Graphs using arrow keys
Laurent Bessard
parents: 1102
diff changeset
   291
            
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   292
    def ResetCursorTick(self):
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   293
        self.CursorTick = None
1084
baa09a1c7b15 Fixed bug in DebugVariablePanel, cursor not reset when graphs were reset
Laurent Bessard
parents: 1044
diff changeset
   294
        self.UpdateCursorTick()
baa09a1c7b15 Fixed bug in DebugVariablePanel, cursor not reset when graphs were reset
Laurent Bessard
parents: 1044
diff changeset
   295
    
baa09a1c7b15 Fixed bug in DebugVariablePanel, cursor not reset when graphs were reset
Laurent Bessard
parents: 1044
diff changeset
   296
    def UpdateCursorTick(self):
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   297
        for panel in self.GraphicPanels:
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   298
            if isinstance(panel, DebugVariableGraphicViewer):
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   299
                panel.SetCursorTick(self.CursorTick)
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   300
        self.ForceRefresh()
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   301
    
929
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   302
    def StartDragNDrop(self, panel, item, x_mouse, y_mouse, x_mouse_start, y_mouse_start):
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   303
        if len(panel.GetItems()) > 1:
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   304
            self.DraggingAxesPanel = DebugVariableGraphicViewer(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
929
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   305
            self.DraggingAxesPanel.SetCursorTick(self.CursorTick)
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   306
            width, height = panel.GetSize()
943
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   307
            self.DraggingAxesPanel.SetSize(wx.Size(width, height))
1044
41bd726aa23c Fixed bugs in DebugVariablePanel
Laurent Bessard
parents: 1043
diff changeset
   308
            self.DraggingAxesPanel.ResetGraphics()
929
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   309
            self.DraggingAxesPanel.SetPosition(wx.Point(0, -height))
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   310
        else:
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   311
            self.DraggingAxesPanel = panel
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   312
        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
   313
        self.DraggingAxesMousePos = wx.Point(
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   314
            x_mouse_start - self.DraggingAxesBoundingBox.x, 
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   315
            y_mouse_start - self.DraggingAxesBoundingBox.y)
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   316
        self.MoveDragNDrop(x_mouse, y_mouse)
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   317
        
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   318
    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
   319
        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
   320
        self.DraggingAxesBoundingBox.y = y_mouse - self.DraggingAxesMousePos.y
934
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   321
        self.RefreshHighlight(x_mouse, y_mouse)
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   322
    
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   323
    def RefreshHighlight(self, x_mouse, y_mouse):
929
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   324
        for idx, panel in enumerate(self.GraphicPanels):
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   325
            x, y = panel.GetPosition()
943
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   326
            width, height = panel.GetSize()
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   327
            rect = wx.Rect(x, y, width, height)
929
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   328
            if (rect.InsideXY(x_mouse, y_mouse) or 
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   329
                idx == 0 and y_mouse < 0 or
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   330
                idx == len(self.GraphicPanels) - 1 and y_mouse > panel.GetPosition()[1]):
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   331
                panel.RefreshHighlight(x_mouse - x, y_mouse - y)
943
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   332
            else:
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   333
                panel.SetHighlight(HIGHLIGHT_NONE)
962
c0dcbbdb0bb1 Fix bug on Windows when drag'n dropping variable to DebugVariablePanel, panel not refreshed
Laurent Bessard
parents: 952
diff changeset
   334
        if wx.Platform == "__WXMSW__":
c0dcbbdb0bb1 Fix bug on Windows when drag'n dropping variable to DebugVariablePanel, panel not refreshed
Laurent Bessard
parents: 952
diff changeset
   335
            self.RefreshView()
c0dcbbdb0bb1 Fix bug on Windows when drag'n dropping variable to DebugVariablePanel, panel not refreshed
Laurent Bessard
parents: 952
diff changeset
   336
        else:
c0dcbbdb0bb1 Fix bug on Windows when drag'n dropping variable to DebugVariablePanel, panel not refreshed
Laurent Bessard
parents: 952
diff changeset
   337
            self.ForceRefresh()
934
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   338
    
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   339
    def ResetHighlight(self):
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   340
        for panel in self.GraphicPanels:
943
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   341
            panel.SetHighlight(HIGHLIGHT_NONE)
962
c0dcbbdb0bb1 Fix bug on Windows when drag'n dropping variable to DebugVariablePanel, panel not refreshed
Laurent Bessard
parents: 952
diff changeset
   342
        if wx.Platform == "__WXMSW__":
c0dcbbdb0bb1 Fix bug on Windows when drag'n dropping variable to DebugVariablePanel, panel not refreshed
Laurent Bessard
parents: 952
diff changeset
   343
            self.RefreshView()
c0dcbbdb0bb1 Fix bug on Windows when drag'n dropping variable to DebugVariablePanel, panel not refreshed
Laurent Bessard
parents: 952
diff changeset
   344
        else:
c0dcbbdb0bb1 Fix bug on Windows when drag'n dropping variable to DebugVariablePanel, panel not refreshed
Laurent Bessard
parents: 952
diff changeset
   345
            self.ForceRefresh()
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   346
    
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   347
    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
   348
        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
   349
    
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   350
    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
   351
        x, y = panel.GetPosition()
943
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   352
        width, height = panel.GetSize()
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   353
        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
   354
        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
   355
        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
   356
        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
   357
        return bbox
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   358
    
943
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   359
    def GetDraggingAxesPosition(self, panel):
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   360
        x, y = panel.GetPosition()
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   361
        return wx.Point(self.DraggingAxesBoundingBox.x - x,
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   362
                        self.DraggingAxesBoundingBox.y - y)
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   363
    
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   364
    def StopDragNDrop(self, variable, x_mouse, y_mouse):
943
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   365
        if self.DraggingAxesPanel not in self.GraphicPanels:
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   366
            self.DraggingAxesPanel.Destroy()
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   367
        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
   368
        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
   369
        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
   370
        for idx, panel in enumerate(self.GraphicPanels):
943
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   371
            panel.SetHighlight(HIGHLIGHT_NONE)
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   372
            xw, yw = panel.GetPosition()
943
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   373
            width, height = panel.GetSize()
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   374
            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
   375
            if bbox.InsideXY(x_mouse, y_mouse):
943
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   376
                panel.ShowButtons(True)
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   377
                merge_type = GRAPH_PARALLEL
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   378
                if isinstance(panel, DebugVariableTextViewer) or panel.Is3DCanvas():
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   379
                    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
   380
                        idx += 1
945
c1159acb0886 Added support for drag'n dropping non-numeric variables
Laurent Bessard
parents: 943
diff changeset
   381
                    wx.CallAfter(self.MoveValue, variable, idx)
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   382
                else:
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   383
                    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
   384
                    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
   385
                        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
   386
                        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
   387
                            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
   388
                        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
   389
                    else:
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   390
                        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
   391
                            idx += 1
945
c1159acb0886 Added support for drag'n dropping non-numeric variables
Laurent Bessard
parents: 943
diff changeset
   392
                        wx.CallAfter(self.MoveValue, variable, idx)
929
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   393
                self.ForceRefresh()
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   394
                return 
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   395
        width, height = self.GraphicsWindow.GetVirtualSize()
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   396
        rect = wx.Rect(0, 0, width, height)
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   397
        if rect.InsideXY(x_mouse, y_mouse):
945
c1159acb0886 Added support for drag'n dropping non-numeric variables
Laurent Bessard
parents: 943
diff changeset
   398
            wx.CallAfter(self.MoveValue, variable, len(self.GraphicPanels))
925
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   399
        self.ForceRefresh()
5f9dd88a605b Added support for drag'n drop variable from one graph to another with visible graph
Laurent Bessard
parents: 924
diff changeset
   400
    
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   401
    def RefreshView(self):
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   402
        self.RefreshCanvasPosition()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   403
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   404
        width, height = self.GraphicsWindow.GetVirtualSize()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   405
        bitmap = wx.EmptyBitmap(width, height)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   406
        dc = wx.BufferedDC(wx.ClientDC(self.GraphicsWindow), bitmap)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   407
        dc.Clear()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   408
        dc.BeginDrawing()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   409
        if self.DraggingAxesPanel is not None:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   410
            destBBox = self.DraggingAxesBoundingBox
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   411
            srcBBox = self.DraggingAxesPanel.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
   412
            
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   413
            srcBmp = _convert_agg_to_wx_bitmap(self.DraggingAxesPanel.get_renderer(), None)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   414
            srcDC = wx.MemoryDC()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   415
            srcDC.SelectObject(srcBmp)
929
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   416
                
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   417
            dc.Blit(destBBox.x, destBBox.y, 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   418
                    int(destBBox.width), int(destBBox.height), 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   419
                    srcDC, srcBBox.x, srcBBox.y)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   420
        dc.EndDrawing()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   421
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   422
        if not self.Fixed or self.Force:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   423
            self.Force = False
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   424
            refresh_graphics = True
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   425
        else:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   426
            refresh_graphics = False
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   427
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   428
        if self.DraggingAxesPanel is not None and self.DraggingAxesPanel not in self.GraphicPanels:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   429
            self.DraggingAxesPanel.RefreshViewer(refresh_graphics)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   430
        for panel in self.GraphicPanels:
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   431
            if isinstance(panel, DebugVariableGraphicViewer):
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   432
                panel.RefreshViewer(refresh_graphics)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   433
            else:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   434
                panel.RefreshViewer()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   435
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   436
        if self.CursorTick is not None:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   437
            tick = self.CursorTick
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   438
        elif len(self.Ticks) > 0:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   439
            tick = self.Ticks[-1]
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   440
        else:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   441
            tick = None
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   442
        if tick is not None:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   443
            self.TickLabel.SetLabel("Tick: %d" % tick)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   444
            tick_duration = int(tick * self.Ticktime)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   445
            not_null = False
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   446
            duration = ""
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   447
            for value, format in [(tick_duration / DAY, "%dd"),
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   448
                                  ((tick_duration % DAY) / HOUR, "%dh"),
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   449
                                  ((tick_duration % HOUR) / MINUTE, "%dm"),
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   450
                                  ((tick_duration % MINUTE) / SECOND, "%ds")]:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   451
                
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   452
                if value > 0 or not_null:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   453
                    duration += format % value
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   454
                    not_null = True
929
c562031146e4 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 928
diff changeset
   455
            
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   456
            duration += "%gms" % (float(tick_duration % SECOND) / MILLISECOND) 
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   457
            self.TickTimeLabel.SetLabel("t: %s" % duration)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   458
        else:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   459
            self.TickLabel.SetLabel("")
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   460
            self.TickTimeLabel.SetLabel("")
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   461
        self.TickSizer.Layout()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   462
    
1207
fb9799a0c0f7 Rewrite DebugVariableTablePanel
Laurent Bessard
parents: 1202
diff changeset
   463
    def SubscribeAllDataConsumers(self):
fb9799a0c0f7 Rewrite DebugVariableTablePanel
Laurent Bessard
parents: 1202
diff changeset
   464
        DebugViewer.SubscribeAllDataConsumers(self)
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   465
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   466
        if self.DataProducer 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
   467
            if self.DataProducer is not None:
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   468
                self.SetTickTime(self.DataProducer.GetTicktime())
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   469
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   470
        for panel in self.GraphicPanels:
1207
fb9799a0c0f7 Rewrite DebugVariableTablePanel
Laurent Bessard
parents: 1202
diff changeset
   471
            panel.SubscribeAllDataConsumers()
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   472
            if panel.ItemsIsEmpty():
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   473
                if panel.HasCapture():
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   474
                    panel.ReleaseMouse()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   475
                self.GraphicPanels.remove(panel)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   476
                panel.Destroy()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   477
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   478
        self.ResetVariableNameMask()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   479
        self.RefreshGraphicsSizer()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   480
        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
   481
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, 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
    def ResetView(self):
1176
f4b434672204 Moved and rewrote DebugViewer and DebusDataConsumer classes
Laurent Bessard
parents: 1174
diff changeset
   483
        self.UnsubscribeAllDataConsumers()
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   484
        
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   485
        self.Fixed = False
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   486
        for panel in self.GraphicPanels:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   487
            panel.Destroy()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   488
        self.GraphicPanels = []
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   489
        self.ResetVariableNameMask()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   490
        self.RefreshGraphicsSizer()
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   491
    
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
   492
    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
   493
        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
   494
            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
   495
            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
   496
        else:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   497
            pos = 0
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   498
            range = 0
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   499
        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
   500
    
932
ebe63100b6d7 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 931
diff changeset
   501
    def ChangeRange(self, dir, tick=None):
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   502
        current_range = self.CurrentRange
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   503
        current_range_idx = self.CanvasRange.GetSelection()
1191
5237f87e035f Fixed values in DebugVariablePanel range selection ComboBox
Laurent Bessard
parents: 1190
diff changeset
   504
        new_range_idx = max(0, min(current_range_idx + dir, len(RANGE_VALUES) - 1))
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   505
        if new_range_idx != current_range_idx:
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   506
            self.CanvasRange.SetSelection(new_range_idx)
1191
5237f87e035f Fixed values in DebugVariablePanel range selection ComboBox
Laurent Bessard
parents: 1190
diff changeset
   507
            self.CurrentRange = RANGE_VALUES[new_range_idx][1] / self.Ticktime
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   508
            if len(self.Ticks) > 0:
932
ebe63100b6d7 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 931
diff changeset
   509
                if tick is None:
ebe63100b6d7 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 931
diff changeset
   510
                    tick = self.StartTick + self.CurrentRange / 2.
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   511
                new_start_tick = tick - (tick - self.StartTick) * self.CurrentRange / current_range 
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   512
                self.StartTick = self.Ticks[numpy.argmin(numpy.abs(self.Ticks - new_start_tick))]
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   513
                self.Fixed = self.StartTick < self.Ticks[-1] - self.CurrentRange
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   514
            self.ForceRefresh()
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   515
    
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   516
    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
   517
        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
   518
            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
   519
                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
   520
            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
   521
                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
   522
            else:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   523
                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
   524
        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
   525
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   526
    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
   527
        try:
1191
5237f87e035f Fixed values in DebugVariablePanel range selection ComboBox
Laurent Bessard
parents: 1190
diff changeset
   528
            self.CurrentRange = RANGE_VALUES[self.CanvasRange.GetSelection()][1] / self.Ticktime
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   529
        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
   530
            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
   531
        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
   532
        event.Skip()
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   533
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   534
    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
   535
        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
   536
            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
   537
            self.Fixed = False
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   538
            self.ResetCursorTick()
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   539
        event.Skip()
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   540
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   541
    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
   542
        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
   543
        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
   544
        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
   545
            values = []
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   546
            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
   547
                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
   548
                    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
   549
                        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
   550
                        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
   551
                            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
   552
                            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
   553
                                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
   554
                            else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   555
                                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
   556
                        else:
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   557
                            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
   558
                    else:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   559
                        values.append("")
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   560
                else:
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   561
                    values.append("")
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   562
            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
   563
            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
   564
        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
   565
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   566
    def OnExportGraphButton(self, event):
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   567
        items = reduce(lambda x, y: x + y,
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   568
                       [panel.GetItems() for panel in self.GraphicPanels],
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   569
                       [])
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   570
        variables = [(item, [entry for entry in item.GetData()])
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   571
                     for item in items
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   572
                     if item.IsNumVariable()]
902
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   573
        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
   574
        event.Skip()
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   575
    
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   576
    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
   577
        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
   578
            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
   579
            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
   580
            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
   581
        event.Skip()
ffa8ee5ee2fe Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents: 898
diff changeset
   582
    
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
   583
    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
   584
        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
   585
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, 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
    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
   587
        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
   588
            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
   589
        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
   590
    
934
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   591
    def IsViewerFirst(self, viewer):
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   592
        return viewer == self.GraphicPanels[0]
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   593
    
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   594
    def IsViewerLast(self, viewer):
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   595
        return viewer == self.GraphicPanels[-1]
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   596
    
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   597
    def HighlightPreviousViewer(self, viewer):
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   598
        if self.IsViewerFirst(viewer):
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   599
            return
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   600
        idx = self.GetViewerIndex(viewer)
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   601
        if idx is None:
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   602
            return
943
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   603
        self.GraphicPanels[idx-1].SetHighlight(HIGHLIGHT_AFTER)
934
fc00c11feff5 Fixed highlights for dropping graphs between the others
Laurent Bessard
parents: 932
diff changeset
   604
    
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   605
    def ResetVariableNameMask(self):
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   606
        items = []
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   607
        for panel in self.GraphicPanels:
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   608
            items.extend(panel.GetItems())
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   609
        if len(items) > 1:
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   610
            self.VariableNameMask = reduce(compute_mask,
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   611
                [item.GetVariable().split('.') for item in items])
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   612
        elif len(items) > 0:
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   613
            self.VariableNameMask = items[0].GetVariable().split('.')[:-1] + ['*']
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   614
        else:
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   615
            self.VariableNameMask = []
931
da4970f6c46c Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 930
diff changeset
   616
        self.MaskLabel.ChangeValue(".".join(self.VariableNameMask))
da4970f6c46c Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 930
diff changeset
   617
        self.MaskLabel.SetInsertionPoint(self.MaskLabel.GetLastPosition())
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   618
            
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   619
    def GetVariableNameMask(self):
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   620
        return self.VariableNameMask
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   621
    
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   622
    def InsertValue(self, iec_path, idx = None, force=False):
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   623
        for panel in self.GraphicPanels:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   624
            if panel.GetItem(iec_path) is not None:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   625
                return
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   626
        if idx is None:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   627
            idx = len(self.GraphicPanels)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   628
        item = DebugVariableItem(self, iec_path, True)
814
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   629
        result = self.AddDataConsumer(iec_path.upper(), item)
5743cbdff669 Integration of PLCOpenEditor into Beremiz
Laurent Bessard
parents:
diff changeset
   630
        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
   631
            
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   632
            if item.IsNumVariable():
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   633
                panel = DebugVariableGraphicViewer(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   634
                if self.CursorTick is not None:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   635
                    panel.SetCursorTick(self.CursorTick)
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
   636
            else:
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   637
                panel = DebugVariableTextViewer(self.GraphicsWindow, self, [item])
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   638
            if idx is not None:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   639
                self.GraphicPanels.insert(idx, panel)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   640
            else:
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   641
                self.GraphicPanels.append(panel)
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   642
            self.ResetVariableNameMask()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   643
            self.RefreshGraphicsSizer()
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   644
            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
   645
    
945
c1159acb0886 Added support for drag'n dropping non-numeric variables
Laurent Bessard
parents: 943
diff changeset
   646
    def MoveValue(self, iec_path, idx = None):
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
   647
        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
   648
            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
   649
        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
   650
        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
   651
        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
   652
            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
   653
            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
   654
                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
   655
                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
   656
        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
   657
            source_panel.RemoveItem(item)
1041
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   658
            source_size = source_panel.GetSize()
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   659
            if source_panel.ItemsIsEmpty():
943
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   660
                if source_panel.HasCapture():
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   661
                    source_panel.ReleaseMouse()
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
   662
                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
   663
                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
   664
            
945
c1159acb0886 Added support for drag'n dropping non-numeric variables
Laurent Bessard
parents: 943
diff changeset
   665
            if item.IsNumVariable():
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   666
                panel = DebugVariableGraphicViewer(self.GraphicsWindow, self, [item], GRAPH_PARALLEL)
1041
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   667
                panel.SetCanvasSize(source_size.width, source_size.height)
945
c1159acb0886 Added support for drag'n dropping non-numeric variables
Laurent Bessard
parents: 943
diff changeset
   668
                if self.CursorTick is not None:
c1159acb0886 Added support for drag'n dropping non-numeric variables
Laurent Bessard
parents: 943
diff changeset
   669
                    panel.SetCursorTick(self.CursorTick)
c1159acb0886 Added support for drag'n dropping non-numeric variables
Laurent Bessard
parents: 943
diff changeset
   670
            else:
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   671
                panel = DebugVariableTextViewer(self.GraphicsWindow, self, [item])
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
   672
            self.GraphicPanels.insert(idx, panel)
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   673
            self.ResetVariableNameMask()
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
   674
            self.RefreshGraphicsSizer()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   675
            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
   676
    
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
   677
    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
   678
        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
   679
        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
   680
        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
   681
            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
   682
            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
   683
                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
   684
                break
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   685
        if source_item is None:
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   686
            item = DebugVariableItem(self, source, True)
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   687
            if item.IsNumVariable():
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   688
                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
   689
                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
   690
                    source_item = item
945
c1159acb0886 Added support for drag'n dropping non-numeric variables
Laurent Bessard
parents: 943
diff changeset
   691
        if source_item is not None and source_item.IsNumVariable():
1041
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   692
            if source_panel is not None:
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   693
                source_size = source_panel.GetSize()
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   694
            else:
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   695
                source_size = 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
   696
            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
   697
            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
   698
            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
   699
                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
   700
                    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
   701
                    (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
   702
                     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
   703
                    return
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   704
                
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
   705
                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
   706
                    source_panel.RemoveItem(source_item)
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   707
                    if source_panel.ItemsIsEmpty():
943
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   708
                        if source_panel.HasCapture():
da7f80e04a54 Fixed panels displaying non-numeric variables in DebugVariablePanel
Laurent Bessard
parents: 938
diff changeset
   709
                            source_panel.ReleaseMouse()
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
   710
                        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
   711
                        source_panel.Destroy()
936
364d178df2d3 Added button for exporting individual graph values to clipboard
Laurent Bessard
parents: 935
diff changeset
   712
            elif (merge_type != graph_type and len(target_panel.Items) == 2):
364d178df2d3 Added button for exporting individual graph values to clipboard
Laurent Bessard
parents: 935
diff changeset
   713
                target_panel.RemoveItem(source_item)
364d178df2d3 Added button for exporting individual graph values to clipboard
Laurent Bessard
parents: 935
diff changeset
   714
            else:
364d178df2d3 Added button for exporting individual graph values to clipboard
Laurent Bessard
parents: 935
diff changeset
   715
                target_panel = None
364d178df2d3 Added button for exporting individual graph values to clipboard
Laurent Bessard
parents: 935
diff changeset
   716
                
364d178df2d3 Added button for exporting individual graph values to clipboard
Laurent Bessard
parents: 935
diff changeset
   717
            if target_panel 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
   718
                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
   719
                target_panel.GraphType = merge_type
1041
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   720
                size = target_panel.GetSize()
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   721
                if merge_type == GRAPH_ORTHOGONAL:
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   722
                    target_panel.SetCanvasSize(size.width, size.width)
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   723
                elif source_size is not None:
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   724
                    target_panel.SetCanvasSize(size.width, size.height + source_size.height)
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   725
                else:
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   726
                    target_panel.SetCanvasSize(size.width, size.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
   727
                target_panel.ResetGraphics()
909
852af7c6f0ef Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents: 907
diff changeset
   728
                
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   729
                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
   730
                self.RefreshGraphicsSizer()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   731
                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
   732
    
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   733
    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
   734
        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
   735
        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
   736
            
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents: 912
diff changeset
   737
            if item is None:
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   738
                source_panel.ClearItems()
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
   739
                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
   740
                self.GraphicPanels.remove(source_panel)
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   741
                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
   742
                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
   743
            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
   744
                source_panel.RemoveItem(item)
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   745
                if source_panel.ItemsIsEmpty():
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
   746
                    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
   747
                    self.GraphicPanels.remove(source_panel)
928
a94e7fea7051 Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents: 927
diff changeset
   748
                    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
   749
                    self.RefreshGraphicsSizer()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   750
            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
   751
    
887
d3c6c4ab8b28 Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents: 878
diff changeset
   752
    def ResetGraphicsValues(self):
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   753
        self.Ticks = numpy.array([])
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   754
        self.StartTick = 0
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   755
        self.Fixed = False
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   756
        for panel in self.GraphicPanels:
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   757
            panel.ResetItemsData()
1198
8b4e6bd0aa92 Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents: 1194
diff changeset
   758
        self.ResetCursorTick()
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
   759
697d8b77d716 Improved matplotlib graphic debug panel implementation, adding force, 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
    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
   761
        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
   762
        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
   763
        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
   764
        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
   765
        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
   766
        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
   767
        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
   768
                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
   769
    
988
30e7571c10d0 Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents: 980
diff changeset
   770
    def OnGraphicsWindowEraseBackground(self, event):
30e7571c10d0 Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents: 980
diff changeset
   771
        pass
30e7571c10d0 Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents: 980
diff changeset
   772
    
30e7571c10d0 Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents: 980
diff changeset
   773
    def OnGraphicsWindowPaint(self, event):
30e7571c10d0 Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents: 980
diff changeset
   774
        self.RefreshView()
30e7571c10d0 Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents: 980
diff changeset
   775
        event.Skip()
30e7571c10d0 Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents: 980
diff changeset
   776
    
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
   777
    def OnGraphicsWindowResize(self, event):
1041
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   778
        size = self.GetSize()
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   779
        for panel in self.GraphicPanels:
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   780
            panel_size = panel.GetSize()
1200
501cb0bb4c05 Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents: 1199
diff changeset
   781
            if (isinstance(panel, DebugVariableGraphicViewer) and 
1193
59c196884fec Moved and start to rewrite DebugVariablePanel splitting it into multiple files
Laurent Bessard
parents: 1192
diff changeset
   782
                panel.GraphType == GRAPH_ORTHOGONAL and 
59c196884fec Moved and start to rewrite DebugVariablePanel splitting it into multiple files
Laurent Bessard
parents: 1192
diff changeset
   783
                panel_size.width == panel_size.height):
1041
736ec395399a Fixed graph panel size when modifying DebugVariablePanel layout
Laurent Bessard
parents: 1040
diff changeset
   784
                panel.SetCanvasSize(size.width, size.width)
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
   785
        self.RefreshGraphicsWindowScrollbars()
1194
0cf48602ee24 Fixed bug with moving cursor with keyboard in DebugVariablePanel
Laurent Bessard
parents: 1193
diff changeset
   786
        self.GraphicsSizer.Layout()
924
5f2cc382be8c Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents: 919
diff changeset
   787
        event.Skip()
1040
af8a1aee3584 Fixed MouseWheel behavior in DebugVariablePanel, change graph range only if CTRL is pressed
Laurent Bessard
parents: 1008
diff changeset
   788
af8a1aee3584 Fixed MouseWheel behavior in DebugVariablePanel, change graph range only if CTRL is pressed
Laurent Bessard
parents: 1008
diff changeset
   789
    def OnGraphicsWindowMouseWheel(self, event):
af8a1aee3584 Fixed MouseWheel behavior in DebugVariablePanel, change graph range only if CTRL is pressed
Laurent Bessard
parents: 1008
diff changeset
   790
        if self.VetoScrollEvent:
af8a1aee3584 Fixed MouseWheel behavior in DebugVariablePanel, change graph range only if CTRL is pressed
Laurent Bessard
parents: 1008
diff changeset
   791
            self.VetoScrollEvent = False
af8a1aee3584 Fixed MouseWheel behavior in DebugVariablePanel, change graph range only if CTRL is pressed
Laurent Bessard
parents: 1008
diff changeset
   792
        else:
af8a1aee3584 Fixed MouseWheel behavior in DebugVariablePanel, change graph range only if CTRL is pressed
Laurent Bessard
parents: 1008
diff changeset
   793
            event.Skip()