author | Laurent Bessard |
Wed, 19 Dec 2012 13:29:38 +0100 | |
changeset 899 | 64aa66d481c5 |
parent 898 | 6b2958f04f30 |
child 902 | ffa8ee5ee2fe |
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(): |
895
f5a28011d551
Fixed boolean value displayed in debug variable panel
Laurent Bessard
parents:
892
diff
changeset
|
100 |
num_value = {True:1., False:0.}.get(value, float(value)) |
f5a28011d551
Fixed boolean value displayed in debug variable panel
Laurent Bessard
parents:
892
diff
changeset
|
101 |
self.Data = numpy.append(self.Data, [[float(tick), num_value]], axis=0) |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
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): |
|
892
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
111 |
if (self.VariableType == "STRING" and value.startswith("'") and value.endswith("'") or |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
112 |
self.VariableType == "WSTRING" and value.startswith('"') and value.endswith('"')): |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
113 |
value = value[1:-1] |
814 | 114 |
if self.Value != value: |
115 |
self.Value = value |
|
116 |
self.Parent.HasNewData = True |
|
117 |
||
118 |
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
|
119 |
if self.VariableType == "STRING": |
878
37256069baed
Fix display of string variables value in debug
Laurent Bessard
parents:
814
diff
changeset
|
120 |
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
|
121 |
elif self.VariableType == "WSTRING": |
878
37256069baed
Fix display of string variables value in debug
Laurent Bessard
parents:
814
diff
changeset
|
122 |
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
|
123 |
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
|
124 |
return "%.6g" % self.Value |
814 | 125 |
return self.Value |
126 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
127 |
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
|
128 |
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
|
129 |
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
|
130 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
131 |
def GetAxis3D(self): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
132 |
if self.IsNumVariable(): |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
133 |
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
|
134 |
return "" |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
135 |
|
814 | 136 |
class DebugVariableTable(CustomTable): |
137 |
||
138 |
def GetValue(self, row, col): |
|
139 |
if row < self.GetNumberRows(): |
|
140 |
return self.GetValueByName(row, self.GetColLabelValue(col, False)) |
|
141 |
return "" |
|
142 |
||
143 |
def SetValue(self, row, col, value): |
|
144 |
if col < len(self.colnames): |
|
145 |
self.SetValueByName(row, self.GetColLabelValue(col, False), value) |
|
146 |
||
147 |
def GetValueByName(self, row, colname): |
|
148 |
if row < self.GetNumberRows(): |
|
149 |
if colname == "Variable": |
|
150 |
return self.data[row].GetVariable() |
|
151 |
elif colname == "Value": |
|
152 |
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
|
153 |
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
|
154 |
return self.data[row].GetAxis3D() |
814 | 155 |
return "" |
156 |
||
157 |
def SetValueByName(self, row, colname, value): |
|
158 |
if row < self.GetNumberRows(): |
|
159 |
if colname == "Variable": |
|
160 |
self.data[row].SetVariable(value) |
|
161 |
elif colname == "Value": |
|
162 |
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
|
163 |
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
|
164 |
self.data[row].SetAxis3D(value) |
814 | 165 |
|
166 |
def IsForced(self, row): |
|
167 |
if row < self.GetNumberRows(): |
|
168 |
return self.data[row].IsForced() |
|
169 |
return False |
|
170 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
171 |
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
|
172 |
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
|
173 |
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
|
174 |
return False |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
175 |
|
814 | 176 |
def _updateColAttrs(self, grid): |
177 |
""" |
|
178 |
wx.grid.Grid -> update the column attributes to add the |
|
179 |
appropriate renderer given the column name. |
|
180 |
||
181 |
Otherwise default to the default renderer. |
|
182 |
""" |
|
183 |
||
184 |
for row in range(self.GetNumberRows()): |
|
185 |
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
|
186 |
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
|
187 |
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
|
188 |
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
|
189 |
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
|
190 |
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
|
191 |
grid.SetReadOnly(row, col, False) |
814 | 192 |
else: |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
193 |
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
|
194 |
else: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
195 |
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
|
196 |
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
|
197 |
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
|
198 |
else: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
199 |
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
|
200 |
grid.SetReadOnly(row, col, True) |
814 | 201 |
self.ResizeRow(grid, row) |
202 |
||
203 |
def AppendItem(self, data): |
|
204 |
self.data.append(data) |
|
205 |
||
206 |
def InsertItem(self, idx, data): |
|
207 |
self.data.insert(idx, data) |
|
208 |
||
209 |
def RemoveItem(self, idx): |
|
210 |
self.data.pop(idx) |
|
211 |
||
212 |
def MoveItem(self, idx, new_idx): |
|
213 |
self.data.insert(new_idx, self.data.pop(idx)) |
|
214 |
||
215 |
def GetItem(self, idx): |
|
216 |
return self.data[idx] |
|
217 |
||
218 |
class DebugVariableDropTarget(wx.TextDropTarget): |
|
219 |
||
220 |
def __init__(self, parent): |
|
221 |
wx.TextDropTarget.__init__(self) |
|
222 |
self.ParentWindow = parent |
|
223 |
||
224 |
def OnDropText(self, x, y, data): |
|
225 |
x, y = self.ParentWindow.VariablesGrid.CalcUnscrolledPosition(x, y) |
|
226 |
row = self.ParentWindow.VariablesGrid.YToRow(y - self.ParentWindow.VariablesGrid.GetColLabelSize()) |
|
227 |
if row == wx.NOT_FOUND: |
|
228 |
row = self.ParentWindow.Table.GetNumberRows() |
|
229 |
message = None |
|
230 |
try: |
|
231 |
values = eval(data) |
|
232 |
except: |
|
233 |
message = _("Invalid value \"%s\" for debug variable")%data |
|
234 |
values = None |
|
235 |
if not isinstance(values, TupleType): |
|
236 |
message = _("Invalid value \"%s\" for debug variable")%data |
|
237 |
values = None |
|
238 |
if values is not None and values[1] == "debug": |
|
239 |
self.ParentWindow.InsertValue(values[0], row) |
|
240 |
if message is not None: |
|
241 |
wx.CallAfter(self.ShowMessage, message) |
|
242 |
||
243 |
def ShowMessage(self, message): |
|
244 |
dialog = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR) |
|
245 |
dialog.ShowModal() |
|
246 |
dialog.Destroy() |
|
247 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
248 |
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
|
249 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
250 |
class DebugVariablePanel(wx.SplitterWindow, DebugViewer): |
814 | 251 |
|
252 |
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
|
253 |
wx.SplitterWindow.__init__(self, parent, style=wx.SP_3D) |
814 | 254 |
DebugViewer.__init__(self, producer, True) |
255 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
256 |
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
|
257 |
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
|
258 |
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
|
259 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
260 |
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
|
261 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
262 |
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
|
263 |
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
|
264 |
main_panel_sizer.AddGrowableRow(1) |
814 | 265 |
|
266 |
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
|
267 |
main_panel_sizer.AddSizer(button_sizer, border=5, |
814 | 268 |
flag=wx.ALIGN_RIGHT|wx.ALL) |
269 |
||
270 |
for name, bitmap, help in [ |
|
271 |
("DeleteButton", "remove_element", _("Remove debug variable")), |
|
272 |
("UpButton", "up", _("Move debug variable up")), |
|
273 |
("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
|
274 |
button = wx.lib.buttons.GenBitmapButton(self.MainPanel, bitmap=GetBitmap(bitmap), |
814 | 275 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
276 |
button.SetToolTipString(help) |
|
277 |
setattr(self, name, button) |
|
278 |
button_sizer.AddWindow(button, border=5, flag=wx.LEFT) |
|
279 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
280 |
self.VariablesGrid = CustomGrid(self.MainPanel, size=wx.Size(-1, 150), style=wx.VSCROLL) |
814 | 281 |
self.VariablesGrid.SetDropTarget(DebugVariableDropTarget(self)) |
282 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, |
|
283 |
self.OnVariablesGridCellRightClick) |
|
892
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
284 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
285 |
self.OnVariablesGridCellLeftClick) |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
286 |
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
|
287 |
self.OnVariablesGridCellChange) |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
288 |
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
|
289 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
290 |
self.MainPanel.SetSizer(main_panel_sizer) |
814 | 291 |
|
292 |
self.HasNewData = False |
|
293 |
||
294 |
self.Table = DebugVariableTable(self, [], GetDebugVariablesTableColnames()) |
|
295 |
self.VariablesGrid.SetTable(self.Table) |
|
296 |
self.VariablesGrid.SetButtons({"Delete": self.DeleteButton, |
|
297 |
"Up": self.UpButton, |
|
298 |
"Down": self.DownButton}) |
|
299 |
||
300 |
def _AddVariable(new_row): |
|
301 |
return self.VariablesGrid.GetGridCursorRow() |
|
302 |
setattr(self.VariablesGrid, "_AddRow", _AddVariable) |
|
303 |
||
304 |
def _DeleteVariable(row): |
|
305 |
item = self.Table.GetItem(row) |
|
306 |
self.RemoveDataConsumer(item) |
|
307 |
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
|
308 |
self.ResetGraphics() |
814 | 309 |
self.RefreshGrid() |
310 |
setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable) |
|
311 |
||
312 |
def _MoveVariable(row, move): |
|
313 |
new_row = max(0, min(row + move, self.Table.GetNumberRows() - 1)) |
|
314 |
if new_row != row: |
|
315 |
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
|
316 |
self.ResetGraphics() |
814 | 317 |
self.RefreshGrid() |
318 |
return new_row |
|
319 |
setattr(self.VariablesGrid, "_MoveRow", _MoveVariable) |
|
320 |
||
321 |
self.VariablesGrid.SetRowLabelSize(0) |
|
322 |
||
323 |
for col in range(self.Table.GetNumberCols()): |
|
324 |
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
|
325 |
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
|
326 |
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
|
327 |
else: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
328 |
attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER) |
814 | 329 |
self.VariablesGrid.SetColAttr(col, attr) |
330 |
self.VariablesGrid.SetColSize(col, 100) |
|
331 |
||
332 |
self.Table.ResetView(self.VariablesGrid) |
|
333 |
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
|
334 |
|
888
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
335 |
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
|
336 |
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
|
337 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
338 |
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
|
339 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
340 |
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
|
341 |
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
|
342 |
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
|
343 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
344 |
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
|
345 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
346 |
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
|
347 |
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
|
348 |
self.GraphicsAxes = [] |
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.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
|
351 |
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
|
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.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
|
354 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
355 |
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
|
356 |
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
|
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.LastMotionTime = gettime() |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
359 |
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
|
360 |
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
|
361 |
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
|
362 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
363 |
self.Graphics3DCanvas = FigureCanvas(self.GraphicsPanel, -1, self.Graphics3DFigure) |
892
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
364 |
self.Graphics3DCanvas.SetMinSize(wx.Size(1, 1)) |
888
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
365 |
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
|
366 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
367 |
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
|
368 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
369 |
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
|
370 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
371 |
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
|
372 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
373 |
else: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
374 |
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
|
375 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
376 |
self.ResetGraphics() |
814 | 377 |
|
378 |
def RefreshNewData(self): |
|
379 |
if self.HasNewData: |
|
380 |
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
|
381 |
self.RefreshGrid(only_values=True) |
814 | 382 |
DebugViewer.RefreshNewData(self) |
383 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
384 |
def RefreshGrid(self, only_values=False): |
814 | 385 |
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
|
386 |
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
|
387 |
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
|
388 |
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
|
389 |
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
|
390 |
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
|
391 |
else: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
392 |
self.Table.ResetView(self.VariablesGrid) |
814 | 393 |
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
|
394 |
|
888
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
395 |
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
|
396 |
# Refresh graphics |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
397 |
idx = 0 |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
398 |
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
|
399 |
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
|
400 |
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
|
401 |
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
|
402 |
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
|
403 |
idx += 1 |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
404 |
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
|
405 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
406 |
# 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
|
407 |
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
|
408 |
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
|
409 |
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
|
410 |
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
|
411 |
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
|
412 |
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
|
413 |
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
|
414 |
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
|
415 |
|
814 | 416 |
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
|
417 |
|
814 | 418 |
def UnregisterObsoleteData(self): |
419 |
items = [(idx, item) for idx, item in enumerate(self.Table.GetData())] |
|
420 |
items.reverse() |
|
421 |
for idx, item in items: |
|
422 |
iec_path = item.GetVariable().upper() |
|
423 |
if self.GetDataType(iec_path) is None: |
|
424 |
self.RemoveDataConsumer(item) |
|
425 |
self.Table.RemoveItem(idx) |
|
426 |
else: |
|
427 |
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
|
428 |
item.RefreshVariableType() |
814 | 429 |
self.Freeze() |
430 |
self.Table.ResetView(self.VariablesGrid) |
|
431 |
self.VariablesGrid.RefreshButtons() |
|
432 |
self.Thaw() |
|
433 |
||
434 |
def ResetGrid(self): |
|
435 |
self.DeleteDataConsumers() |
|
436 |
self.Table.Empty() |
|
437 |
self.Freeze() |
|
438 |
self.Table.ResetView(self.VariablesGrid) |
|
439 |
self.VariablesGrid.RefreshButtons() |
|
440 |
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
|
441 |
self.ResetGraphics() |
814 | 442 |
|
443 |
def GetForceVariableMenuFunction(self, iec_path, item): |
|
444 |
iec_type = self.GetDataType(iec_path) |
|
445 |
def ForceVariableFunction(event): |
|
446 |
if iec_type is not None: |
|
447 |
dialog = ForceVariableDialog(self, iec_type, str(item.GetValue())) |
|
448 |
if dialog.ShowModal() == wx.ID_OK: |
|
449 |
self.ForceDataValue(iec_path, dialog.GetValue()) |
|
450 |
return ForceVariableFunction |
|
451 |
||
452 |
def GetReleaseVariableMenuFunction(self, iec_path): |
|
453 |
def ReleaseVariableFunction(event): |
|
454 |
self.ReleaseDataValue(iec_path) |
|
455 |
return ReleaseVariableFunction |
|
456 |
||
892
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
457 |
def OnVariablesGridCellLeftClick(self, event): |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
458 |
if event.GetCol() == 0: |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
459 |
row = event.GetRow() |
898
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
895
diff
changeset
|
460 |
data = wx.TextDataObject(str((self.Table.GetValueByName(row, "Variable"), "debug"))) |
892
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
461 |
dragSource = wx.DropSource(self.VariablesGrid) |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
462 |
dragSource.SetData(data) |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
463 |
dragSource.DoDragDrop() |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
464 |
event.Skip() |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
465 |
|
814 | 466 |
def OnVariablesGridCellRightClick(self, event): |
467 |
row, col = event.GetRow(), event.GetCol() |
|
468 |
if self.Table.GetColLabelValue(col, False) == "Value": |
|
469 |
iec_path = self.Table.GetValueByName(row, "Variable").upper() |
|
470 |
||
471 |
menu = wx.Menu(title='') |
|
472 |
||
473 |
new_id = wx.NewId() |
|
474 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Force value")) |
|
475 |
self.Bind(wx.EVT_MENU, self.GetForceVariableMenuFunction(iec_path.upper(), self.Table.GetItem(row)), id=new_id) |
|
476 |
||
477 |
new_id = wx.NewId() |
|
478 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Release value")) |
|
479 |
self.Bind(wx.EVT_MENU, self.GetReleaseVariableMenuFunction(iec_path.upper()), id=new_id) |
|
480 |
||
481 |
if self.Table.IsForced(row): |
|
482 |
menu.Enable(new_id, True) |
|
483 |
else: |
|
484 |
menu.Enable(new_id, False) |
|
485 |
||
486 |
self.PopupMenu(menu) |
|
487 |
||
488 |
menu.Destroy() |
|
489 |
event.Skip() |
|
490 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
491 |
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
|
492 |
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
|
493 |
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
|
494 |
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
|
495 |
event.Skip() |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
496 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
497 |
def InsertValue(self, iec_path, idx = None, force=False, axis3D=False): |
814 | 498 |
if idx is None: |
499 |
idx = self.Table.GetNumberRows() |
|
500 |
for item in self.Table.GetData(): |
|
501 |
if iec_path == item.GetVariable(): |
|
502 |
return |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
503 |
item = VariableTableItem(self, iec_path) |
814 | 504 |
result = self.AddDataConsumer(iec_path.upper(), item) |
505 |
if result is not None or force: |
|
506 |
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
|
507 |
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
|
508 |
self.ResetGraphics() |
814 | 509 |
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
|
510 |
|
814 | 511 |
def GetDebugVariables(self): |
512 |
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
|
513 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
514 |
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
|
515 |
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
|
516 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
517 |
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
|
518 |
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
|
519 |
item.ResetData() |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
520 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
521 |
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
|
522 |
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
|
523 |
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
|
524 |
self.GraphicsAxes = [] |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
525 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
526 |
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
|
527 |
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
|
528 |
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
|
529 |
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
|
530 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
531 |
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
|
532 |
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
|
533 |
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
|
534 |
else: |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
535 |
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
|
536 |
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
|
537 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
538 |
self.RefreshGraphicsCanvasWindowScrollbars() |
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
539 |
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
|
540 |
|
baf5dbfd28f4
Adding support for disabling 2D and 3D graphics in DebugVariablePanel when matplotlib is not installed
Laurent Bessard
parents:
887
diff
changeset
|
541 |
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
|
542 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
543 |
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
|
544 |
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
|
545 |
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
|
546 |
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
|
547 |
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
|
548 |
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
|
549 |
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
|
550 |
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
|
551 |
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
|
552 |
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
|
553 |
else: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
554 |
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
|
555 |
else: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
556 |
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
|
557 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
558 |
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
|
559 |
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
|
560 |
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
|
561 |
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
|
562 |
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
|
563 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
564 |
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
|
565 |
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
|
566 |
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
|
567 |
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
|
568 |
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
|
569 |
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
|
570 |
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
|
571 |
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
|
572 |
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
|
573 |
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
|
574 |
|
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
575 |
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
|
576 |
self.RefreshGraphicsCanvasWindowScrollbars() |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
577 |
event.Skip() |