author | Laurent Bessard |
Fri, 15 Jun 2012 18:03:25 +0200 | |
changeset 713 | 95a0a427f3ef |
parent 711 | 5f6a743dcde5 |
child 714 | 131ea7f237b9 |
permissions | -rw-r--r-- |
711
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
1 |
#!/usr/bin/env python |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
3 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
4 |
#This file is part of PLCOpenEditor, a library implementing an IEC 61131-3 editor |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
5 |
#based on the plcopen standard. |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
6 |
# |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
7 |
#Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
8 |
# |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
9 |
#See COPYING file for copyrights details. |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
10 |
# |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
11 |
#This library is free software; you can redistribute it and/or |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
12 |
#modify it under the terms of the GNU General Public |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
13 |
#License as published by the Free Software Foundation; either |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
14 |
#version 2.1 of the License, or (at your option) any later version. |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
15 |
# |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
16 |
#This library is distributed in the hope that it will be useful, |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
17 |
#but WITHOUT ANY WARRANTY; without even the implied warranty of |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
18 |
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
19 |
#General Public License for more details. |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
20 |
# |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
21 |
#You should have received a copy of the GNU General Public |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
22 |
#License along with this library; if not, write to the Free Software |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
23 |
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
24 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
25 |
import wx |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
26 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
27 |
from graphics import DebugDataConsumer, DebugViewer |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
28 |
from controls import CustomGrid, CustomTable |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
29 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
30 |
def GetDebugVariablesTableColnames(): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
31 |
_ = lambda x : x |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
32 |
return [_("Variable"), _("Value")] |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
33 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
34 |
class VariableTableItem(DebugDataConsumer): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
35 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
36 |
def __init__(self, parent, variable, value): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
37 |
DebugDataConsumer.__init__(self) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
38 |
self.Parent = parent |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
39 |
self.Variable = variable |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
40 |
self.Value = value |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
41 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
42 |
def __del__(self): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
43 |
self.Parent = None |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
44 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
45 |
def SetVariable(self, variable): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
46 |
if self.Parent and self.Variable != variable: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
47 |
self.Variable = variable |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
48 |
self.Parent.RefreshGrid() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
49 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
50 |
def GetVariable(self): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
51 |
return self.Variable |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
52 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
53 |
def SetForced(self, forced): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
54 |
if self.Forced != forced: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
55 |
self.Forced = forced |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
56 |
self.Parent.HasNewData = True |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
57 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
58 |
def SetValue(self, value): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
59 |
if self.Value != value: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
60 |
self.Value = value |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
61 |
self.Parent.HasNewData = True |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
62 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
63 |
def GetValue(self): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
64 |
return self.Value |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
65 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
66 |
class DebugVariableTable(CustomTable): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
67 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
68 |
def GetValue(self, row, col): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
69 |
if row < self.GetNumberRows(): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
70 |
return self.GetValueByName(row, self.GetColLabelValue(col, False)) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
71 |
return "" |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
72 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
73 |
def SetValue(self, row, col, value): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
74 |
if col < len(self.colnames): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
75 |
self.SetValueByName(row, self.GetColLabelValue(col, False), value) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
76 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
77 |
def GetValueByName(self, row, colname): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
78 |
if row < self.GetNumberRows(): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
79 |
if colname == "Variable": |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
80 |
return self.data[row].GetVariable() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
81 |
elif colname == "Value": |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
82 |
return self.data[row].GetValue() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
83 |
return "" |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
84 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
85 |
def SetValueByName(self, row, colname, value): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
86 |
if row < self.GetNumberRows(): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
87 |
if colname == "Variable": |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
88 |
self.data[row].SetVariable(value) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
89 |
elif colname == "Value": |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
90 |
self.data[row].SetValue(value) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
91 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
92 |
def IsForced(self, row): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
93 |
if row < self.GetNumberRows(): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
94 |
return self.data[row].IsForced() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
95 |
return False |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
96 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
97 |
def _updateColAttrs(self, grid): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
98 |
""" |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
99 |
wx.grid.Grid -> update the column attributes to add the |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
100 |
appropriate renderer given the column name. |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
101 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
102 |
Otherwise default to the default renderer. |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
103 |
""" |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
104 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
105 |
for row in range(self.GetNumberRows()): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
106 |
for col in range(self.GetNumberCols()): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
107 |
if self.GetColLabelValue(col, False) == "Value": |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
108 |
if self.IsForced(row): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
109 |
grid.SetCellTextColour(row, col, wx.BLUE) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
110 |
else: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
111 |
grid.SetCellTextColour(row, col, wx.BLACK) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
112 |
grid.SetReadOnly(row, col, True) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
113 |
self.ResizeRow(grid, row) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
114 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
115 |
def AppendItem(self, data): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
116 |
self.data.append(data) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
117 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
118 |
def InsertItem(self, idx, data): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
119 |
self.data.insert(idx, data) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
120 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
121 |
def RemoveItem(self, idx): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
122 |
self.data.pop(idx) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
123 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
124 |
def MoveItem(self, idx, new_idx): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
125 |
self.data.insert(new_idx, self.data.pop(idx)) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
126 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
127 |
def GetItem(self, idx): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
128 |
return self.data[idx] |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
129 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
130 |
class DebugVariableDropTarget(wx.TextDropTarget): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
131 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
132 |
def __init__(self, parent): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
133 |
wx.TextDropTarget.__init__(self) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
134 |
self.ParentWindow = parent |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
135 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
136 |
def OnDropText(self, x, y, data): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
137 |
x, y = self.ParentWindow.VariablesGrid.CalcUnscrolledPosition(x, y) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
138 |
row = self.ParentWindow.VariablesGrid.YToRow(y - self.ParentWindow.VariablesGrid.GetColLabelSize()) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
139 |
if row == wx.NOT_FOUND: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
140 |
row = self.ParentWindow.Table.GetNumberRows() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
141 |
message = None |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
142 |
try: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
143 |
values = eval(data) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
144 |
except: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
145 |
message = _("Invalid value \"%s\" for debug variable")%data |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
146 |
values = None |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
147 |
if not isinstance(values, TupleType): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
148 |
message = _("Invalid value \"%s\" for debug variable")%data |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
149 |
values = None |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
150 |
if values is not None and values[1] == "debug": |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
151 |
self.ParentWindow.InsertValue(values[0], row) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
152 |
if message is not None: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
153 |
wx.CallAfter(self.ShowMessage, message) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
154 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
155 |
def ShowMessage(self, message): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
156 |
dialog = wx.MessageDialog(self.ParentWindow, message, _("Error"), wx.OK|wx.ICON_ERROR) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
157 |
dialog.ShowModal() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
158 |
dialog.Destroy() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
159 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
160 |
class DebugVariablePanel(wx.Panel, DebugViewer): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
161 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
162 |
def __init__(self, parent, window, producer): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
163 |
wx.Panel.__init__(self, parent, style=wx.TAB_TRAVERSAL) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
164 |
DebugViewer.__init__(self, producer, True) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
165 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
166 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
167 |
main_sizer.AddGrowableCol(0) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
168 |
main_sizer.AddGrowableRow(1) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
169 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
170 |
button_sizer = wx.BoxSizer(wx.HORIZONTAL) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
171 |
main_sizer.AddSizer(button_sizer, border=5, |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
172 |
flag=wx.ALIGN_RIGHT|wx.ALL) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
173 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
174 |
up_button = wx.Button(self, label='^', size=wx.Size(28, 28)) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
175 |
button_sizer.AddWindow(up_button, border=5, flag=wx.RIGHT) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
176 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
177 |
down_button = wx.Button(self, label='v', size=wx.Size(28, 28)) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
178 |
button_sizer.AddWindow(down_button, border=5, flag=wx.RIGHT) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
179 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
180 |
delete_button = wx.Button(self, label=_('Delete'), size=wx.DefaultSize) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
181 |
button_sizer.AddWindow(delete_button) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
182 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
183 |
self.VariablesGrid = CustomGrid(self, size=wx.Size(0, 150), style=wx.VSCROLL) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
184 |
self.VariablesGrid.SetDropTarget(DebugVariableDropTarget(self)) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
185 |
self.VariablesGrid.Bind(wx.grid.EVT_GRID_CELL_RIGHT_CLICK, |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
186 |
self.OnVariablesGridCellRightClick) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
187 |
main_sizer.AddWindow(self.VariablesGrid, flag=wx.GROW) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
188 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
189 |
self.SetSizer(main_sizer) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
190 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
191 |
self.HasNewData = False |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
192 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
193 |
self.Table = DebugVariableTable(self, [], GetDebugVariablesTableColnames()) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
194 |
self.VariablesGrid.SetTable(self.Table) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
195 |
self.VariablesGrid.SetButtons({"Delete": delete_button, |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
196 |
"Up": up_button, |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
197 |
"Down": down_button}) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
198 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
199 |
def _AddVariable(new_row): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
200 |
return self.VariablesGrid.GetGridCursorRow() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
201 |
setattr(self.VariablesGrid, "_AddRow", _AddVariable) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
202 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
203 |
def _DeleteVariable(row): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
204 |
item = self.Table.GetItem(row) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
205 |
self.RemoveDataConsumer(item) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
206 |
self.Table.RemoveItem(row) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
207 |
self.RefreshGrid() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
208 |
setattr(self.VariablesGrid, "_DeleteRow", _DeleteVariable) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
209 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
210 |
def _MoveVariable(row, move): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
211 |
new_row = max(0, min(row + move, self.Table.GetNumberRows() - 1)) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
212 |
if new_row != row: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
213 |
self.Table.MoveItem(row, new_row) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
214 |
self.RefreshGrid() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
215 |
return new_row |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
216 |
setattr(self.VariablesGrid, "_MoveRow", _MoveVariable) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
217 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
218 |
self.VariablesGrid.SetRowLabelSize(0) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
219 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
220 |
for col in range(self.Table.GetNumberCols()): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
221 |
attr = wx.grid.GridCellAttr() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
222 |
attr.SetAlignment(wx.ALIGN_RIGHT, wx.ALIGN_CENTER) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
223 |
self.VariablesGrid.SetColAttr(col, attr) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
224 |
self.VariablesGrid.SetColSize(col, 100) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
225 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
226 |
self.Table.ResetView(self.VariablesGrid) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
227 |
self.VariablesGrid.RefreshButtons() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
228 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
229 |
def RefreshNewData(self): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
230 |
if self.HasNewData: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
231 |
self.HasNewData = False |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
232 |
self.RefreshGrid() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
233 |
DebugViewer.RefreshNewData(self) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
234 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
235 |
def RefreshGrid(self): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
236 |
self.Freeze() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
237 |
self.Table.ResetView(self.VariablesGrid) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
238 |
self.VariablesGrid.RefreshButtons() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
239 |
self.Thaw() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
240 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
241 |
def UnregisterObsoleteData(self): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
242 |
items = [(idx, item) for idx, item in enumerate(self.Table.GetData())] |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
243 |
items.reverse() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
244 |
for idx, item in items: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
245 |
iec_path = item.GetVariable().upper() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
246 |
if self.GetDataType(iec_path) is None: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
247 |
self.RemoveDataConsumer(item) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
248 |
self.Table.RemoveItem(idx) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
249 |
else: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
250 |
self.AddDataConsumer(iec_path, item) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
251 |
self.Freeze() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
252 |
self.Table.ResetView(self.VariablesGrid) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
253 |
self.VariablesGrid.RefreshButtons() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
254 |
self.Thaw() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
255 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
256 |
def ResetGrid(self): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
257 |
self.DeleteDataConsumers() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
258 |
self.Table.Empty() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
259 |
self.Freeze() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
260 |
self.Table.ResetView(self.VariablesGrid) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
261 |
self.VariablesGrid.RefreshButtons() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
262 |
self.Thaw() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
263 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
264 |
def GetForceVariableMenuFunction(self, iec_path, item): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
265 |
iec_type = self.GetDataType(iec_path) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
266 |
def ForceVariableFunction(event): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
267 |
if iec_type is not None: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
268 |
dialog = ForceVariableDialog(self, iec_type, str(item.GetValue())) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
269 |
if dialog.ShowModal() == wx.ID_OK: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
270 |
self.ForceDataValue(iec_path, dialog.GetValue()) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
271 |
return ForceVariableFunction |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
272 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
273 |
def GetReleaseVariableMenuFunction(self, iec_path): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
274 |
def ReleaseVariableFunction(event): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
275 |
self.ReleaseDataValue(iec_path) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
276 |
return ReleaseVariableFunction |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
277 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
278 |
def OnVariablesGridCellRightClick(self, event): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
279 |
row, col = event.GetRow(), event.GetCol() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
280 |
if self.Table.GetColLabelValue(col, False) == "Value": |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
281 |
iec_path = self.Table.GetValueByName(row, "Variable").upper() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
282 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
283 |
menu = wx.Menu(title='') |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
284 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
285 |
new_id = wx.NewId() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
286 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Force value")) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
287 |
self.Bind(wx.EVT_MENU, self.GetForceVariableMenuFunction(iec_path.upper(), self.Table.GetItem(row)), id=new_id) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
288 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
289 |
new_id = wx.NewId() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
290 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Release value")) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
291 |
self.Bind(wx.EVT_MENU, self.GetReleaseVariableMenuFunction(iec_path.upper()), id=new_id) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
292 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
293 |
if self.Table.IsForced(row): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
294 |
menu.Enable(new_id, True) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
295 |
else: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
296 |
menu.Enable(new_id, False) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
297 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
298 |
self.PopupMenu(menu) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
299 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
300 |
menu.Destroy() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
301 |
event.Skip() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
302 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
303 |
def InsertValue(self, iec_path, idx = None, force=False): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
304 |
if idx is None: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
305 |
idx = self.Table.GetNumberRows() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
306 |
for item in self.Table.GetData(): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
307 |
if iec_path == item.GetVariable(): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
308 |
return |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
309 |
item = VariableTableItem(self, iec_path, "") |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
310 |
result = self.AddDataConsumer(iec_path.upper(), item) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
311 |
if result is not None or force: |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
312 |
self.Table.InsertItem(idx, item) |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
313 |
self.RefreshGrid() |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
314 |
|
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
315 |
def GetDebugVariables(self): |
5f6a743dcde5
Adding support for exporting graph value to csv formatted string to clipboard
Laurent Bessard
parents:
diff
changeset
|
316 |
return [item.GetVariable() for item in self.Table.GetData()] |