author | Laurent Bessard |
Mon, 03 Dec 2012 12:31:27 +0100 | |
changeset 890 | b3cafb73c5e9 |
parent 888 | baf5dbfd28f4 |
child 892 | 771581a6b0be |
permissions | -rw-r--r-- |
814 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
4 |
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
|
5 |
#based on the plcopen standard. |
|
6 |
# |
|
7 |
#Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD |
|
8 |
# |
|
9 |
#See COPYING file for copyrights details. |
|
10 |
# |
|
11 |
#This library is free software; you can redistribute it and/or |
|
12 |
#modify it under the terms of the GNU General Public |
|
13 |
#License as published by the Free Software Foundation; either |
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
|
15 |
# |
|
16 |
#This library is distributed in the hope that it will be useful, |
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
19 |
#General Public License for more details. |
|
20 |
# |
|
21 |
#You should have received a copy of the GNU General Public |
|
22 |
#License along with this library; if not, write to the Free Software |
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|
24 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
25 |
from types import TupleType, FloatType |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
26 |
from time import time as gettime |
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 | 28 |
|
29 |
import wx |
|
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 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
32 |
try: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
33 |
import matplotlib |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
34 |
matplotlib.use('WX') |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
35 |
import matplotlib.pyplot |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
36 |
from matplotlib.backends.backend_wx import FigureCanvasWx as FigureCanvas |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
37 |
from mpl_toolkits.mplot3d import Axes3D |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
38 |
USE_MPL = True |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
39 |
except: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
40 |
USE_MPL = False |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
41 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
42 |
from graphics import DebugDataConsumer, DebugViewer, REFRESH_PERIOD |
814 | 43 |
from controls import CustomGrid, CustomTable |
44 |
from dialogs.ForceVariableDialog import ForceVariableDialog |
|
45 |
from util.BitmapLibrary import GetBitmap |
|
46 |
||
47 |
def AppendMenu(parent, help, id, kind, text): |
|
48 |
parent.Append(help=help, id=id, kind=kind, text=text) |
|
49 |
||
50 |
def GetDebugVariablesTableColnames(): |
|
51 |
_ = lambda x : x |
|
888
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
52 |
cols = [_("Variable"), _("Value")] |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
53 |
if USE_MPL: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
54 |
cols.append(_("3DAxis")) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
55 |
return cols |
814 | 56 |
|
57 |
class VariableTableItem(DebugDataConsumer): |
|
58 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
59 |
def __init__(self, parent, variable): |
814 | 60 |
DebugDataConsumer.__init__(self) |
61 |
self.Parent = parent |
|
62 |
self.Variable = variable |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
63 |
self.RefreshVariableType() |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
64 |
self.Value = "" |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
65 |
self.Axis3D = False |
814 | 66 |
|
67 |
def __del__(self): |
|
68 |
self.Parent = None |
|
69 |
||
70 |
def SetVariable(self, variable): |
|
71 |
if self.Parent and self.Variable != variable: |
|
72 |
self.Variable = variable |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
73 |
self.RefreshVariableType() |
814 | 74 |
self.Parent.RefreshGrid() |
75 |
||
76 |
def GetVariable(self): |
|
77 |
return self.Variable |
|
78 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
79 |
def RefreshVariableType(self): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
80 |
self.VariableType = self.Parent.GetDataType(self.Variable) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
81 |
self.ResetData() |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
82 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
83 |
def GetVariableType(self): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
84 |
return self.VariableType |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
85 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
86 |
def GetData(self): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
87 |
return self.Data |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
88 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
89 |
def ResetData(self): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
90 |
if self.IsNumVariable(): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
91 |
self.Data = numpy.array([]).reshape(0, 2) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
92 |
else: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
93 |
self.Data = None |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
94 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
95 |
def IsNumVariable(self): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
96 |
return self.Parent.IsNumType(self.VariableType) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
97 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
98 |
def NewValue(self, tick, value, forced=False): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
99 |
if self.IsNumVariable(): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
100 |
value = {True:1., False:0.}.get(value, float(value)) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
101 |
self.Data = numpy.append(self.Data, [[float(tick), value]], axis=0) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
102 |
self.Parent.HasNewData = True |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
103 |
DebugDataConsumer.NewValue(self, tick, value, forced) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
104 |
|
814 | 105 |
def SetForced(self, forced): |
106 |
if self.Forced != forced: |
|
107 |
self.Forced = forced |
|
108 |
self.Parent.HasNewData = True |
|
109 |
||
110 |
def SetValue(self, value): |
|
111 |
if self.Value != value: |
|
112 |
self.Value = value |
|
113 |
self.Parent.HasNewData = True |
|
114 |
||
115 |
def GetValue(self): |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
116 |
if self.VariableType == "STRING": |
878
37256069baed
Fix display of string variables value in debug
Laurent Bessard
parents:
814
diff
changeset
|
117 |
return "'%s'" % self.Value |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
118 |
elif self.VariableType == "WSTRING": |
878
37256069baed
Fix display of string variables value in debug
Laurent Bessard
parents:
814
diff
changeset
|
119 |
return "\"%s\"" % self.Value |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
120 |
elif isinstance(self.Value, FloatType): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
121 |
return "%.6g" % self.Value |
814 | 122 |
return self.Value |
123 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
124 |
def SetAxis3D(self, axis_3d): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
125 |
if self.IsNumVariable(): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
126 |
self.Axis3D = axis_3d |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
127 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
128 |
def GetAxis3D(self): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
129 |
if self.IsNumVariable(): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
130 |
return self.Axis3D |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
131 |
return "" |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
132 |
|
814 | 133 |
class DebugVariableTable(CustomTable): |
134 |
||
135 |
def GetValue(self, row, col): |
|
136 |
if row < self.GetNumberRows(): |
|
137 |
return self.GetValueByName(row, self.GetColLabelValue(col, False)) |
|
138 |
return "" |
|
139 |
||
140 |
def SetValue(self, row, col, value): |
|
141 |
if col < len(self.colnames): |
|
142 |
self.SetValueByName(row, self.GetColLabelValue(col, False), value) |
|
143 |
||
144 |
def GetValueByName(self, row, colname): |
|
145 |
if row < self.GetNumberRows(): |
|
146 |
if colname == "Variable": |
|
147 |
return self.data[row].GetVariable() |
|
148 |
elif colname == "Value": |
|
149 |
return self.data[row].GetValue() |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
150 |
elif colname == "3DAxis": |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
151 |
return self.data[row].GetAxis3D() |
814 | 152 |
return "" |
153 |
||
154 |
def SetValueByName(self, row, colname, value): |
|
155 |
if row < self.GetNumberRows(): |
|
156 |
if colname == "Variable": |
|
157 |
self.data[row].SetVariable(value) |
|
158 |
elif colname == "Value": |
|
159 |
self.data[row].SetValue(value) |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
160 |
elif colname == "3DAxis": |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
161 |
self.data[row].SetAxis3D(value) |
814 | 162 |
|
163 |
def IsForced(self, row): |
|
164 |
if row < self.GetNumberRows(): |
|
165 |
return self.data[row].IsForced() |
|
166 |
return False |
|
167 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
168 |
def IsNumVariable(self, row): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
169 |
if row < self.GetNumberRows(): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
170 |
return self.data[row].IsNumVariable() |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
171 |
return False |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
172 |
|
814 | 173 |
def _updateColAttrs(self, grid): |
174 |
""" |
|
175 |
wx.grid.Grid -> update the column attributes to add the |
|
176 |
appropriate renderer given the column name. |
|
177 |
||
178 |
Otherwise default to the default renderer. |
|
179 |
""" |
|
180 |
||
181 |
for row in range(self.GetNumberRows()): |
|
182 |
for col in range(self.GetNumberCols()): |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
183 |
colname = self.GetColLabelValue(col, False) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
184 |
if colname == "3DAxis": |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
185 |
if self.IsNumVariable(row): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
186 |
grid.SetCellRenderer(row, col, wx.grid.GridCellBoolRenderer()) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
187 |
grid.SetCellEditor(row, col, wx.grid.GridCellBoolEditor()) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
188 |
grid.SetReadOnly(row, col, False) |
814 | 189 |
else: |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
190 |
grid.SetReadOnly(row, col, True) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
191 |
else: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
192 |
if colname == "Value": |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
193 |
if self.IsForced(row): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
194 |
grid.SetCellTextColour(row, col, wx.BLUE) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
195 |
else: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
196 |
grid.SetCellTextColour(row, col, wx.BLACK) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
197 |
grid.SetReadOnly(row, col, True) |
814 | 198 |
self.ResizeRow(grid, row) |
199 |
||
200 |
def AppendItem(self, data): |
|
201 |
self.data.append(data) |
|
202 |
||
203 |
def InsertItem(self, idx, data): |
|
204 |
self.data.insert(idx, data) |
|
205 |
||
206 |
def RemoveItem(self, idx): |
|
207 |
self.data.pop(idx) |
|
208 |
||
209 |
def MoveItem(self, idx, new_idx): |
|
210 |
self.data.insert(new_idx, self.data.pop(idx)) |
|
211 |
||
212 |
def GetItem(self, idx): |
|
213 |
return self.data[idx] |
|
214 |
||
215 |
class DebugVariableDropTarget(wx.TextDropTarget): |
|
216 |
||
217 |
def __init__(self, parent): |
|
218 |
wx.TextDropTarget.__init__(self) |
|
219 |
self.ParentWindow = parent |
|
220 |
||
221 |
def OnDropText(self, x, y, data): |
|
222 |
x, y = self.ParentWindow.VariablesGrid.CalcUnscrolledPosition(x, y) |
|
223 |
row = self.ParentWindow.VariablesGrid.YToRow(y - self.ParentWindow.VariablesGrid.GetColLabelSize()) |
|
224 |
if row == wx.NOT_FOUND: |
|
225 |
row = self.ParentWindow.Table.GetNumberRows() |
|
226 |
message = None |
|
227 |
try: |
|
228 |
values = eval(data) |
|
229 |
except: |
|
230 |
message = _("Invalid value \"%s\" for debug variable")%data |
|
231 |
values = None |
|
232 |
if not isinstance(values, TupleType): |
|
233 |
message = _("Invalid value \"%s\" for debug variable")%data |
|
234 |
values = None |
|
235 |
if values is not None and values[1] == "debug": |
|
236 |
self.ParentWindow.InsertValue(values[0], row) |
|
237 |
if message is not None: |
|
238 |
wx.CallAfter(self.ShowMessage, message) |
|
239 |
||
240 |
def ShowMessage(self, message): |
|
241 |
dialog = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR) |
|
242 |
dialog.ShowModal() |
|
243 |
dialog.Destroy() |
|
244 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
245 |
SCROLLBAR_UNIT = 10 |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
246 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
247 |
class DebugVariablePanel(wx.SplitterWindow, DebugViewer): |
814 | 248 |
|
249 |
def __init__(self, parent, producer): |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
250 |
wx.SplitterWindow.__init__(self, parent, style=wx.SP_3D) |
814 | 251 |
DebugViewer.__init__(self, producer, True) |
252 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
253 |
self.SetSashGravity(0.5) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
254 |
self.SetNeedUpdating(True) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
255 |
self.SetMinimumPaneSize(1) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
256 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
257 |
self.MainPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
258 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
259 |
main_panel_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
260 |
main_panel_sizer.AddGrowableCol(0) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
261 |
main_panel_sizer.AddGrowableRow(1) |
814 | 262 |
|
263 |
button_sizer = wx.BoxSizer(wx.HORIZONTAL) |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
264 |
main_panel_sizer.AddSizer(button_sizer, border=5, |
814 | 265 |
flag=wx.ALIGN_RIGHT|wx.ALL) |
266 |
||
267 |
for name, bitmap, help in [ |
|
268 |
("DeleteButton", "remove_element", _("Remove debug variable")), |
|
269 |
("UpButton", "up", _("Move debug variable up")), |
|
270 |
("DownButton", "down", _("Move debug variable down"))]: |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
271 |
button = wx.lib.buttons.GenBitmapButton(self.MainPanel, bitmap=GetBitmap(bitmap), |
814 | 272 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
273 |
button.SetToolTipString(help) |
|
274 |
setattr(self, name, button) |
|
275 |
button_sizer.AddWindow(button, border=5, flag=wx.LEFT) |
|
276 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
277 |
self.VariablesGrid = CustomGrid(self.MainPanel, size=wx.Size(-1, 150), style=wx.VSCROLL) |
814 | 278 |
self.VariablesGrid.SetDropTarget(DebugVariableDropTarget(self)) |
279 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, |
|
280 |
self.OnVariablesGridCellRightClick) |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
281 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_CHANGE, |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
282 |
self.OnVariablesGridCellChange) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
283 |
main_panel_sizer.AddWindow(self.VariablesGrid, flag=wx.GROW) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
284 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
285 |
self.MainPanel.SetSizer(main_panel_sizer) |
814 | 286 |
|
287 |
self.HasNewData = False |
|
288 |
||
289 |
self.Table = DebugVariableTable(self, [], GetDebugVariablesTableColnames()) |
|
290 |
self.VariablesGrid.SetTable(self.Table) |
|
291 |
self.VariablesGrid.SetButtons({"Delete": self.DeleteButton, |
|
292 |
"Up": self.UpButton, |
|
293 |
"Down": self.DownButton}) |
|
294 |
||
295 |
def _AddVariable(new_row): |
|
296 |
return self.VariablesGrid.GetGridCursorRow() |
|
297 |
setattr(self.VariablesGrid, "_AddRow", _AddVariable) |
|
298 |
||
299 |
def _DeleteVariable(row): |
|
300 |
item = self.Table.GetItem(row) |
|
301 |
self.RemoveDataConsumer(item) |
|
302 |
self.Table.RemoveItem(row) |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
303 |
self.ResetGraphics() |
814 | 304 |
self.RefreshGrid() |
305 |
setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable) |
|
306 |
||
307 |
def _MoveVariable(row, move): |
|
308 |
new_row = max(0, min(row + move, self.Table.GetNumberRows() - 1)) |
|
309 |
if new_row != row: |
|
310 |
self.Table.MoveItem(row, new_row) |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
311 |
self.ResetGraphics() |
814 | 312 |
self.RefreshGrid() |
313 |
return new_row |
|
314 |
setattr(self.VariablesGrid, "_MoveRow", _MoveVariable) |
|
315 |
||
316 |
self.VariablesGrid.SetRowLabelSize(0) |
|
317 |
||
318 |
for col in range(self.Table.GetNumberCols()): |
|
319 |
attr = wx.grid.GridCellAttr() |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
320 |
if self.Table.GetColLabelValue(col, False) == "3DAxis": |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
321 |
attr.SetAlignment(wx.ALIGN_CENTER, wx.ALIGN_CENTER) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
322 |
else: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
323 |
attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER) |
814 | 324 |
self.VariablesGrid.SetColAttr(col, attr) |
325 |
self.VariablesGrid.SetColSize(col, 100) |
|
326 |
||
327 |
self.Table.ResetView(self.VariablesGrid) |
|
328 |
self.VariablesGrid.RefreshButtons() |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
329 |
|
888
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
330 |
if USE_MPL: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
331 |
self.GraphicsPanel = wx.Panel(self, style=wx.TAB_TRAVERSAL) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
332 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
333 |
graphics_panel_sizer = wx.BoxSizer(wx.VERTICAL) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
334 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
335 |
self.GraphicsCanvasWindow = wx.ScrolledWindow(self.GraphicsPanel, style=wx.HSCROLL|wx.VSCROLL) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
336 |
self.GraphicsCanvasWindow.Bind(wx.EVT_SIZE, self.OnGraphicsCanvasWindowResize) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
337 |
graphics_panel_sizer.AddWindow(self.GraphicsCanvasWindow, 1, flag=wx.GROW) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
338 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
339 |
graphics_canvas_window_sizer = wx.BoxSizer(wx.VERTICAL) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
340 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
341 |
self.GraphicsFigure = matplotlib.figure.Figure() |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
342 |
self.GraphicsFigure.subplots_adjust(hspace=0) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
343 |
self.GraphicsAxes = [] |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
344 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
345 |
self.GraphicsCanvas = FigureCanvas(self.GraphicsCanvasWindow, -1, self.GraphicsFigure) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
346 |
graphics_canvas_window_sizer.AddWindow(self.GraphicsCanvas, 1, flag=wx.GROW) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
347 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
348 |
self.GraphicsCanvasWindow.SetSizer(graphics_canvas_window_sizer) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
349 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
350 |
self.Graphics3DFigure = matplotlib.figure.Figure() |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
351 |
self.Graphics3DFigure.subplotpars.update(left=0.0, right=1.0, bottom=0.0, top=1.0) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
352 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
353 |
self.LastMotionTime = gettime() |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
354 |
self.Graphics3DAxes = self.Graphics3DFigure.gca(projection='3d') |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
355 |
self.Graphics3DAxes.set_color_cycle(['b']) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
356 |
setattr(self.Graphics3DAxes, "_on_move", self.OnGraphics3DMotion) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
357 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
358 |
self.Graphics3DCanvas = FigureCanvas(self.GraphicsPanel, -1, self.Graphics3DFigure) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
359 |
self.Graphics3DCanvas.SetMinSize(wx.Size(0, 0)) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
360 |
graphics_panel_sizer.AddWindow(self.Graphics3DCanvas, 1, flag=wx.GROW) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
361 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
362 |
self.Graphics3DAxes.mouse_init() |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
363 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
364 |
self.GraphicsPanel.SetSizer(graphics_panel_sizer) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
365 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
366 |
self.SplitHorizontally(self.MainPanel, self.GraphicsPanel, -200) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
367 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
368 |
else: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
369 |
self.Initialize(self.MainPanel) |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
370 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
371 |
self.ResetGraphics() |
814 | 372 |
|
373 |
def RefreshNewData(self): |
|
374 |
if self.HasNewData: |
|
375 |
self.HasNewData = False |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
376 |
self.RefreshGrid(only_values=True) |
814 | 377 |
DebugViewer.RefreshNewData(self) |
378 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
379 |
def RefreshGrid(self, only_values=False): |
814 | 380 |
self.Freeze() |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
381 |
if only_values: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
382 |
for col in xrange(self.Table.GetNumberCols()): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
383 |
if self.Table.GetColLabelValue(col, False) == "Value": |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
384 |
for row in xrange(self.Table.GetNumberRows()): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
385 |
self.VariablesGrid.SetCellValue(row, col, str(self.Table.GetValueByName(row, "Value"))) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
386 |
else: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
387 |
self.Table.ResetView(self.VariablesGrid) |
814 | 388 |
self.VariablesGrid.RefreshButtons() |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
389 |
|
888
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
390 |
if USE_MPL: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
391 |
# Refresh graphics |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
392 |
idx = 0 |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
393 |
for item in self.Table.GetData(): |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
394 |
data = item.GetData() |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
395 |
if data is not None: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
396 |
self.GraphicsAxes[idx].clear() |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
397 |
self.GraphicsAxes[idx].plot(data[:, 0], data[:, 1]) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
398 |
idx += 1 |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
399 |
self.GraphicsCanvas.draw() |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
400 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
401 |
# Refresh 3D graphics |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
402 |
while len(self.Graphics3DAxes.lines) > 0: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
403 |
self.Graphics3DAxes.lines.pop() |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
404 |
if self.Axis3DValues is not None: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
405 |
self.Graphics3DAxes.plot( |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
406 |
self.Axis3DValues[0][1].GetData()[self.Axis3DValues[0][0]:, 1], |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
407 |
self.Axis3DValues[1][1].GetData()[self.Axis3DValues[1][0]:, 1], |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
408 |
zs = self.Axis3DValues[2][1].GetData()[self.Axis3DValues[2][0]:, 1]) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
409 |
self.Graphics3DCanvas.draw() |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
410 |
|
814 | 411 |
self.Thaw() |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
412 |
|
814 | 413 |
def UnregisterObsoleteData(self): |
414 |
items = [(idx, item) for idx, item in enumerate(self.Table.GetData())] |
|
415 |
items.reverse() |
|
416 |
for idx, item in items: |
|
417 |
iec_path = item.GetVariable().upper() |
|
418 |
if self.GetDataType(iec_path) is None: |
|
419 |
self.RemoveDataConsumer(item) |
|
420 |
self.Table.RemoveItem(idx) |
|
421 |
else: |
|
422 |
self.AddDataConsumer(iec_path, item) |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
423 |
item.RefreshVariableType() |
814 | 424 |
self.Freeze() |
425 |
self.Table.ResetView(self.VariablesGrid) |
|
426 |
self.VariablesGrid.RefreshButtons() |
|
427 |
self.Thaw() |
|
428 |
||
429 |
def ResetGrid(self): |
|
430 |
self.DeleteDataConsumers() |
|
431 |
self.Table.Empty() |
|
432 |
self.Freeze() |
|
433 |
self.Table.ResetView(self.VariablesGrid) |
|
434 |
self.VariablesGrid.RefreshButtons() |
|
435 |
self.Thaw() |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
436 |
self.ResetGraphics() |
814 | 437 |
|
438 |
def GetForceVariableMenuFunction(self, iec_path, item): |
|
439 |
iec_type = self.GetDataType(iec_path) |
|
440 |
def ForceVariableFunction(event): |
|
441 |
if iec_type is not None: |
|
442 |
dialog = ForceVariableDialog(self, iec_type, str(item.GetValue())) |
|
443 |
if dialog.ShowModal() == wx.ID_OK: |
|
444 |
self.ForceDataValue(iec_path, dialog.GetValue()) |
|
445 |
return ForceVariableFunction |
|
446 |
||
447 |
def GetReleaseVariableMenuFunction(self, iec_path): |
|
448 |
def ReleaseVariableFunction(event): |
|
449 |
self.ReleaseDataValue(iec_path) |
|
450 |
return ReleaseVariableFunction |
|
451 |
||
452 |
def OnVariablesGridCellRightClick(self, event): |
|
453 |
row, col = event.GetRow(), event.GetCol() |
|
454 |
if self.Table.GetColLabelValue(col, False) == "Value": |
|
455 |
iec_path = self.Table.GetValueByName(row, "Variable").upper() |
|
456 |
||
457 |
menu = wx.Menu(title='') |
|
458 |
||
459 |
new_id = wx.NewId() |
|
460 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Force value")) |
|
461 |
self.Bind(wx.EVT_MENU, self.GetForceVariableMenuFunction(iec_path.upper(), self.Table.GetItem(row)), id=new_id) |
|
462 |
||
463 |
new_id = wx.NewId() |
|
464 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Release value")) |
|
465 |
self.Bind(wx.EVT_MENU, self.GetReleaseVariableMenuFunction(iec_path.upper()), id=new_id) |
|
466 |
||
467 |
if self.Table.IsForced(row): |
|
468 |
menu.Enable(new_id, True) |
|
469 |
else: |
|
470 |
menu.Enable(new_id, False) |
|
471 |
||
472 |
self.PopupMenu(menu) |
|
473 |
||
474 |
menu.Destroy() |
|
475 |
event.Skip() |
|
476 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
477 |
def OnVariablesGridCellChange(self, event): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
478 |
row, col = event.GetRow(), event.GetCol() |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
479 |
if self.Table.GetColLabelValue(col, False) == "3DAxis": |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
480 |
wx.CallAfter(self.Reset3DGraphics) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
481 |
event.Skip() |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
482 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
483 |
def InsertValue(self, iec_path, idx = None, force=False, axis3D=False): |
814 | 484 |
if idx is None: |
485 |
idx = self.Table.GetNumberRows() |
|
486 |
for item in self.Table.GetData(): |
|
487 |
if iec_path == item.GetVariable(): |
|
488 |
return |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
489 |
item = VariableTableItem(self, iec_path) |
814 | 490 |
result = self.AddDataConsumer(iec_path.upper(), item) |
491 |
if result is not None or force: |
|
492 |
self.Table.InsertItem(idx, item) |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
493 |
item.SetAxis3D(int(axis3D)) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
494 |
self.ResetGraphics() |
814 | 495 |
self.RefreshGrid() |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
496 |
|
814 | 497 |
def GetDebugVariables(self): |
498 |
return [item.GetVariable() for item in self.Table.GetData()] |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
499 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
500 |
def GetAxis3D(self): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
501 |
return [item.GetVariable() for item in self.Table.GetData() if item.GetAxis3D()] |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
502 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
503 |
def ResetGraphicsValues(self): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
504 |
for item in self.Table.GetData(): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
505 |
item.ResetData() |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
506 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
507 |
def ResetGraphics(self): |
888
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
508 |
if USE_MPL: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
509 |
self.GraphicsFigure.clear() |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
510 |
self.GraphicsAxes = [] |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
511 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
512 |
axes_num = 0 |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
513 |
for item in self.Table.GetData(): |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
514 |
if item.IsNumVariable(): |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
515 |
axes_num += 1 |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
516 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
517 |
for idx in xrange(axes_num): |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
518 |
if idx == 0: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
519 |
axes = self.GraphicsFigure.add_subplot(axes_num, 1, idx + 1) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
520 |
else: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
521 |
axes = self.GraphicsFigure.add_subplot(axes_num, 1, idx + 1, sharex=self.GraphicsAxes[0]) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
522 |
self.GraphicsAxes.append(axes) |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
523 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
524 |
self.RefreshGraphicsCanvasWindowScrollbars() |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
525 |
self.GraphicsCanvas.draw() |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
526 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
527 |
self.Reset3DGraphics() |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
528 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
529 |
def Reset3DGraphics(self): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
530 |
axis = [item for item in self.Table.GetData() if item.GetAxis3D()] |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
531 |
if len(axis) == 3: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
532 |
max_tick = None |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
533 |
xaxis, yaxis, zaxis = [item.GetData() for item in axis] |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
534 |
if len(xaxis) > 0 and len(yaxis) > 0 and len(zaxis) > 0: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
535 |
max_tick = max(xaxis[0, 0], yaxis[0, 0], zaxis[0, 0]) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
536 |
if max_tick is not None: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
537 |
self.Axis3DValues = [(numpy.argmin(abs(item.GetData()[:, 0] - max_tick)), item) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
538 |
for item in axis] |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
539 |
else: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
540 |
self.Axis3DValues = [(0, item) for item in axis] |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
541 |
else: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
542 |
self.Axis3DValues = None |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
543 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
544 |
def OnGraphics3DMotion(self, event): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
545 |
current_time = gettime() |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
546 |
if current_time - self.LastMotionTime > REFRESH_PERIOD: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
547 |
self.LastMotionTime = current_time |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
548 |
Axes3D._on_move(self.Graphics3DAxes, event) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
549 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
550 |
def RefreshGraphicsCanvasWindowScrollbars(self): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
551 |
xstart, ystart = self.GraphicsCanvasWindow.GetViewStart() |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
552 |
window_size = self.GraphicsCanvasWindow.GetClientSize() |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
553 |
vwidth, vheight = (window_size[0], (len(self.GraphicsAxes) + 1) * 50) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
554 |
self.GraphicsCanvas.SetMinSize(wx.Size(vwidth, vheight)) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
555 |
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
|
556 |
posy = max(0, min(ystart, (vheight - window_size[1]) / SCROLLBAR_UNIT)) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
557 |
self.GraphicsCanvasWindow.Scroll(posx, posy) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
558 |
self.GraphicsCanvasWindow.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
559 |
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
|
560 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
561 |
def OnGraphicsCanvasWindowResize(self, event): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
562 |
self.RefreshGraphicsCanvasWindowScrollbars() |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
563 |
event.Skip() |