author | Laurent Bessard |
Fri, 31 May 2013 11:36:30 +0200 | |
changeset 1203 | 4399ddd024e5 |
parent 1202 | 3d8c87ab2b5d |
child 1207 | fb9799a0c0f7 |
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 |
||
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
25 |
from types import TupleType |
814 | 26 |
|
27 |
import wx |
|
28 |
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
|
29 |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
30 |
from editors.DebugViewer import DebugViewer |
814 | 31 |
from controls import CustomGrid, CustomTable |
32 |
from dialogs.ForceVariableDialog import ForceVariableDialog |
|
33 |
from util.BitmapLibrary import GetBitmap |
|
34 |
||
1199
fc0e7d80494f
Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents:
1198
diff
changeset
|
35 |
from DebugVariableItem import DebugVariableItem |
fc0e7d80494f
Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents:
1198
diff
changeset
|
36 |
|
814 | 37 |
def GetDebugVariablesTableColnames(): |
38 |
_ = lambda x : x |
|
909
852af7c6f0ef
Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents:
907
diff
changeset
|
39 |
return [_("Variable"), _("Value")] |
924
5f2cc382be8c
Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents:
919
diff
changeset
|
40 |
|
814 | 41 |
class DebugVariableTable(CustomTable): |
42 |
||
43 |
def GetValue(self, row, col): |
|
44 |
if row < self.GetNumberRows(): |
|
45 |
return self.GetValueByName(row, self.GetColLabelValue(col, False)) |
|
46 |
return "" |
|
47 |
||
48 |
def SetValue(self, row, col, value): |
|
49 |
if col < len(self.colnames): |
|
50 |
self.SetValueByName(row, self.GetColLabelValue(col, False), value) |
|
51 |
||
52 |
def GetValueByName(self, row, colname): |
|
53 |
if row < self.GetNumberRows(): |
|
54 |
if colname == "Variable": |
|
55 |
return self.data[row].GetVariable() |
|
56 |
elif colname == "Value": |
|
57 |
return self.data[row].GetValue() |
|
58 |
return "" |
|
59 |
||
60 |
def SetValueByName(self, row, colname, value): |
|
61 |
if row < self.GetNumberRows(): |
|
62 |
if colname == "Variable": |
|
63 |
self.data[row].SetVariable(value) |
|
64 |
elif colname == "Value": |
|
65 |
self.data[row].SetValue(value) |
|
66 |
||
67 |
def IsForced(self, row): |
|
68 |
if row < self.GetNumberRows(): |
|
69 |
return self.data[row].IsForced() |
|
70 |
return False |
|
71 |
||
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
72 |
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
|
73 |
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
|
74 |
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
|
75 |
return False |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
76 |
|
814 | 77 |
def _updateColAttrs(self, grid): |
78 |
""" |
|
79 |
wx.grid.Grid -> update the column attributes to add the |
|
80 |
appropriate renderer given the column name. |
|
81 |
||
82 |
Otherwise default to the default renderer. |
|
83 |
""" |
|
84 |
||
85 |
for row in range(self.GetNumberRows()): |
|
86 |
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
|
87 |
colname = self.GetColLabelValue(col, False) |
909
852af7c6f0ef
Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents:
907
diff
changeset
|
88 |
if colname == "Value": |
852af7c6f0ef
Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents:
907
diff
changeset
|
89 |
if self.IsForced(row): |
852af7c6f0ef
Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents:
907
diff
changeset
|
90 |
grid.SetCellTextColour(row, col, wx.BLUE) |
814 | 91 |
else: |
909
852af7c6f0ef
Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents:
907
diff
changeset
|
92 |
grid.SetCellTextColour(row, col, wx.BLACK) |
852af7c6f0ef
Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents:
907
diff
changeset
|
93 |
grid.SetReadOnly(row, col, True) |
814 | 94 |
self.ResizeRow(grid, row) |
95 |
||
96 |
def AppendItem(self, data): |
|
97 |
self.data.append(data) |
|
98 |
||
99 |
def InsertItem(self, idx, data): |
|
100 |
self.data.insert(idx, data) |
|
101 |
||
102 |
def RemoveItem(self, idx): |
|
103 |
self.data.pop(idx) |
|
104 |
||
105 |
def MoveItem(self, idx, new_idx): |
|
106 |
self.data.insert(new_idx, self.data.pop(idx)) |
|
107 |
||
108 |
def GetItem(self, idx): |
|
109 |
return self.data[idx] |
|
110 |
||
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
111 |
class DebugVariableTableDropTarget(wx.TextDropTarget): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
112 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
113 |
def __init__(self, parent): |
814 | 114 |
wx.TextDropTarget.__init__(self) |
115 |
self.ParentWindow = parent |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
116 |
|
916
697d8b77d716
Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents:
912
diff
changeset
|
117 |
def __del__(self): |
697d8b77d716
Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents:
912
diff
changeset
|
118 |
self.ParentWindow = None |
928
a94e7fea7051
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
927
diff
changeset
|
119 |
|
814 | 120 |
def OnDropText(self, x, y, data): |
121 |
message = None |
|
122 |
try: |
|
123 |
values = eval(data) |
|
124 |
except: |
|
125 |
message = _("Invalid value \"%s\" for debug variable")%data |
|
126 |
values = None |
|
127 |
if not isinstance(values, TupleType): |
|
128 |
message = _("Invalid value \"%s\" for debug variable")%data |
|
129 |
values = None |
|
909
852af7c6f0ef
Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents:
907
diff
changeset
|
130 |
|
814 | 131 |
if message is not None: |
132 |
wx.CallAfter(self.ShowMessage, message) |
|
909
852af7c6f0ef
Adding support for change DebugVariablePanel 2D graphs layout using drag'n drop
Laurent Bessard
parents:
907
diff
changeset
|
133 |
elif values is not None and values[1] == "debug": |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
134 |
grid = self.ParentWindow.VariablesGrid |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
135 |
x, y = grid.CalcUnscrolledPosition(x, y) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
136 |
row = grid.YToRow(y - grid.GetColLabelSize()) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
137 |
if row == wx.NOT_FOUND: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
138 |
row = self.ParentWindow.Table.GetNumberRows() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
139 |
self.ParentWindow.InsertValue(values[0], row, force=True) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
140 |
|
814 | 141 |
def ShowMessage(self, message): |
142 |
dialog = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR) |
|
143 |
dialog.ShowModal() |
|
144 |
dialog.Destroy() |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
145 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
146 |
class DebugVariableTablePanel(wx.Panel, DebugViewer): |
814 | 147 |
|
902
ffa8ee5ee2fe
Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents:
898
diff
changeset
|
148 |
def __init__(self, parent, producer, window): |
916
697d8b77d716
Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents:
912
diff
changeset
|
149 |
wx.Panel.__init__(self, parent, style=wx.SP_3D|wx.TAB_TRAVERSAL) |
902
ffa8ee5ee2fe
Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents:
898
diff
changeset
|
150 |
|
ffa8ee5ee2fe
Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents:
898
diff
changeset
|
151 |
self.ParentWindow = window |
ffa8ee5ee2fe
Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents:
898
diff
changeset
|
152 |
|
814 | 153 |
self.HasNewData = False |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
154 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
155 |
DebugViewer.__init__(self, producer, True) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
156 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
157 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
158 |
main_sizer.AddGrowableCol(0) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
159 |
main_sizer.AddGrowableRow(1) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
160 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
161 |
button_sizer = wx.BoxSizer(wx.HORIZONTAL) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
162 |
main_sizer.AddSizer(button_sizer, border=5, |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
163 |
flag=wx.ALIGN_RIGHT|wx.ALL) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
164 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
165 |
for name, bitmap, help in [ |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
166 |
("DeleteButton", "remove_element", _("Remove debug variable")), |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
167 |
("UpButton", "up", _("Move debug variable up")), |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
168 |
("DownButton", "down", _("Move debug variable down"))]: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
169 |
button = wx.lib.buttons.GenBitmapButton(self, bitmap=GetBitmap(bitmap), |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
170 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
171 |
button.SetToolTipString(help) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
172 |
setattr(self, name, button) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
173 |
button_sizer.AddWindow(button, border=5, flag=wx.LEFT) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
174 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
175 |
self.VariablesGrid = CustomGrid(self, size=wx.Size(-1, 150), style=wx.VSCROLL) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
176 |
self.VariablesGrid.SetDropTarget(DebugVariableTableDropTarget(self)) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
177 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
178 |
self.OnVariablesGridCellRightClick) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
179 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_LEFT_CLICK, |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
180 |
self.OnVariablesGridCellLeftClick) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
181 |
main_sizer.AddWindow(self.VariablesGrid, flag=wx.GROW) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
182 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
183 |
self.Table = DebugVariableTable(self, [], GetDebugVariablesTableColnames()) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
184 |
self.VariablesGrid.SetTable(self.Table) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
185 |
self.VariablesGrid.SetButtons({"Delete": self.DeleteButton, |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
186 |
"Up": self.UpButton, |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
187 |
"Down": self.DownButton}) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
188 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
189 |
def _AddVariable(new_row): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
190 |
return self.VariablesGrid.GetGridCursorRow() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
191 |
setattr(self.VariablesGrid, "_AddRow", _AddVariable) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
192 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
193 |
def _DeleteVariable(row): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
194 |
item = self.Table.GetItem(row) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
195 |
self.RemoveDataConsumer(item) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
196 |
self.Table.RemoveItem(row) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
197 |
self.RefreshView() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
198 |
setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
199 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
200 |
def _MoveVariable(row, move): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
201 |
new_row = max(0, min(row + move, self.Table.GetNumberRows() - 1)) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
202 |
if new_row != row: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
203 |
self.Table.MoveItem(row, new_row) |
916
697d8b77d716
Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents:
912
diff
changeset
|
204 |
self.RefreshView() |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
205 |
return new_row |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
206 |
setattr(self.VariablesGrid, "_MoveRow", _MoveVariable) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
207 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
208 |
self.VariablesGrid.SetRowLabelSize(0) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
209 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
210 |
self.GridColSizes = [200, 100] |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
211 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
212 |
for col in range(self.Table.GetNumberCols()): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
213 |
attr = wx.grid.GridCellAttr() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
214 |
attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
215 |
self.VariablesGrid.SetColAttr(col, attr) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
216 |
self.VariablesGrid.SetColSize(col, self.GridColSizes[col]) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
217 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
218 |
self.Table.ResetView(self.VariablesGrid) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
219 |
self.VariablesGrid.RefreshButtons() |
1192
d8783c0c7d80
Fixed bugs in DebugVariablePanel with ticktime modifications
Laurent Bessard
parents:
1191
diff
changeset
|
220 |
|
916
697d8b77d716
Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents:
912
diff
changeset
|
221 |
self.SetSizer(main_sizer) |
1192
d8783c0c7d80
Fixed bugs in DebugVariablePanel with ticktime modifications
Laurent Bessard
parents:
1191
diff
changeset
|
222 |
|
902
ffa8ee5ee2fe
Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents:
898
diff
changeset
|
223 |
def RefreshNewData(self, *args, **kwargs): |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
224 |
if self.HasNewData: |
814 | 225 |
self.HasNewData = False |
916
697d8b77d716
Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents:
912
diff
changeset
|
226 |
self.RefreshView(only_values=True) |
902
ffa8ee5ee2fe
Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents:
898
diff
changeset
|
227 |
DebugViewer.RefreshNewData(self, *args, **kwargs) |
ffa8ee5ee2fe
Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents:
898
diff
changeset
|
228 |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
229 |
def RefreshView(self, only_values=False): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
230 |
self.Freeze() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
231 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
232 |
if only_values: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
233 |
for col in xrange(self.Table.GetNumberCols()): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
234 |
if self.Table.GetColLabelValue(col, False) == "Value": |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
235 |
for row in xrange(self.Table.GetNumberRows()): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
236 |
self.VariablesGrid.SetCellValue(row, col, str(self.Table.GetValueByName(row, "Value"))) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
237 |
if self.Table.IsForced(row): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
238 |
self.VariablesGrid.SetCellTextColour(row, col, wx.BLUE) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
239 |
else: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
240 |
self.VariablesGrid.SetCellTextColour(row, col, wx.BLACK) |
929
c562031146e4
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
928
diff
changeset
|
241 |
else: |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
242 |
self.Table.ResetView(self.VariablesGrid) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
243 |
self.VariablesGrid.RefreshButtons() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
244 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
245 |
self.Thaw() |
916
697d8b77d716
Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents:
912
diff
changeset
|
246 |
|
1202
3d8c87ab2b5d
Fixed bug when export all items values to clipboard in DebugVariablePanel
Laurent Bessard
parents:
1199
diff
changeset
|
247 |
def UnsubscribeObsoleteData(self): |
1176
f4b434672204
Moved and rewrote DebugViewer and DebusDataConsumer classes
Laurent Bessard
parents:
1174
diff
changeset
|
248 |
self.SubscribeAllDataConsumers() |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
249 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
250 |
items = [(idx, item) for idx, item in enumerate(self.Table.GetData())] |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
251 |
items.reverse() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
252 |
for idx, item in items: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
253 |
iec_path = item.GetVariable() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
254 |
if self.GetDataType(iec_path) is None: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
255 |
self.RemoveDataConsumer(item) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
256 |
self.Table.RemoveItem(idx) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
257 |
else: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
258 |
self.AddDataConsumer(iec_path.upper(), item) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
259 |
item.RefreshVariableType() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
260 |
self.Freeze() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
261 |
self.Table.ResetView(self.VariablesGrid) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
262 |
self.VariablesGrid.RefreshButtons() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
263 |
self.Thaw() |
916
697d8b77d716
Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents:
912
diff
changeset
|
264 |
|
697d8b77d716
Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents:
912
diff
changeset
|
265 |
def ResetView(self): |
1176
f4b434672204
Moved and rewrote DebugViewer and DebusDataConsumer classes
Laurent Bessard
parents:
1174
diff
changeset
|
266 |
self.UnsubscribeAllDataConsumers() |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
267 |
|
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
268 |
self.Table.Empty() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
269 |
self.Freeze() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
270 |
self.Table.ResetView(self.VariablesGrid) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
271 |
self.VariablesGrid.RefreshButtons() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
272 |
self.Thaw() |
902
ffa8ee5ee2fe
Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents:
898
diff
changeset
|
273 |
|
814 | 274 |
def GetForceVariableMenuFunction(self, iec_path, item): |
275 |
iec_type = self.GetDataType(iec_path) |
|
276 |
def ForceVariableFunction(event): |
|
277 |
if iec_type is not None: |
|
278 |
dialog = ForceVariableDialog(self, iec_type, str(item.GetValue())) |
|
279 |
if dialog.ShowModal() == wx.ID_OK: |
|
1102 | 280 |
self.ForceDataValue(iec_path.upper(), dialog.GetValue()) |
814 | 281 |
return ForceVariableFunction |
282 |
||
283 |
def GetReleaseVariableMenuFunction(self, iec_path): |
|
284 |
def ReleaseVariableFunction(event): |
|
285 |
self.ReleaseDataValue(iec_path) |
|
286 |
return ReleaseVariableFunction |
|
287 |
||
892
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
288 |
def OnVariablesGridCellLeftClick(self, event): |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
289 |
if event.GetCol() == 0: |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
290 |
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
|
291 |
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
|
292 |
dragSource = wx.DropSource(self.VariablesGrid) |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
293 |
dragSource.SetData(data) |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
294 |
dragSource.DoDragDrop() |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
295 |
event.Skip() |
771581a6b0be
Fix bug with representation of string variable value in DebugVariablePanel
Laurent Bessard
parents:
888
diff
changeset
|
296 |
|
814 | 297 |
def OnVariablesGridCellRightClick(self, event): |
298 |
row, col = event.GetRow(), event.GetCol() |
|
299 |
if self.Table.GetColLabelValue(col, False) == "Value": |
|
300 |
iec_path = self.Table.GetValueByName(row, "Variable").upper() |
|
301 |
||
302 |
menu = wx.Menu(title='') |
|
303 |
||
304 |
new_id = wx.NewId() |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
305 |
menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Force value")) |
814 | 306 |
self.Bind(wx.EVT_MENU, self.GetForceVariableMenuFunction(iec_path.upper(), self.Table.GetItem(row)), id=new_id) |
307 |
||
308 |
new_id = wx.NewId() |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
309 |
menu.Append(help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Release value")) |
814 | 310 |
self.Bind(wx.EVT_MENU, self.GetReleaseVariableMenuFunction(iec_path.upper()), id=new_id) |
311 |
||
312 |
if self.Table.IsForced(row): |
|
313 |
menu.Enable(new_id, True) |
|
314 |
else: |
|
315 |
menu.Enable(new_id, False) |
|
316 |
||
317 |
self.PopupMenu(menu) |
|
318 |
||
319 |
menu.Destroy() |
|
320 |
event.Skip() |
|
321 |
||
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
322 |
def InsertValue(self, iec_path, idx = None, force=False): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
323 |
for item in self.Table.GetData(): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
324 |
if iec_path == item.GetVariable(): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
325 |
return |
934
fc00c11feff5
Fixed highlights for dropping graphs between the others
Laurent Bessard
parents:
932
diff
changeset
|
326 |
if idx is None: |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
327 |
idx = self.Table.GetNumberRows() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
328 |
item = DebugVariableItem(self, iec_path) |
814 | 329 |
result = self.AddDataConsumer(iec_path.upper(), item) |
330 |
if result is not None or force: |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
331 |
self.Table.InsertItem(idx, item) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
332 |
self.RefreshView() |
916
697d8b77d716
Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents:
912
diff
changeset
|
333 |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
334 |
def ResetGraphicsValues(self): |
988
30e7571c10d0
Reduced flicker on LogViewer and DebugGraphPanel on Windows
Laurent Bessard
parents:
980
diff
changeset
|
335 |
pass |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
336 |