author | Laurent Bessard |
Wed, 26 Jun 2013 16:54:38 +0200 | |
changeset 1269 | e8e153a7c3bf |
parent 1238 | 24577755485d |
child 1277 | 358db9d64aa1 |
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 |
||
25 |
import wx |
|
26 |
import wx.lib.buttons |
|
27 |
import wx.lib.agw.customtreectrl as CT |
|
28 |
||
930
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
29 |
try: |
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
30 |
import matplotlib |
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
31 |
matplotlib.use('WX') |
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
32 |
USE_MPL = True |
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
33 |
except: |
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
34 |
USE_MPL = False |
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
35 |
|
826
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
36 |
from PLCControler import ITEMS_VARIABLE, ITEM_CONFIGURATION, ITEM_RESOURCE, ITEM_POU, ITEM_TRANSITION, ITEM_ACTION |
814 | 37 |
from util.BitmapLibrary import GetBitmap |
38 |
||
39 |
class PouInstanceVariablesPanel(wx.Panel): |
|
40 |
||
41 |
def __init__(self, parent, window, controller, debug): |
|
42 |
wx.Panel.__init__(self, name='PouInstanceTreePanel', |
|
43 |
parent=parent, pos=wx.Point(0, 0), |
|
44 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
45 |
||
46 |
self.ParentButton = wx.lib.buttons.GenBitmapButton(self, |
|
47 |
bitmap=GetBitmap("top"), size=wx.Size(28, 28), style=wx.NO_BORDER) |
|
48 |
self.ParentButton.SetToolTipString(_("Parent instance")) |
|
49 |
self.Bind(wx.EVT_BUTTON, self.OnParentButtonClick, |
|
50 |
self.ParentButton) |
|
51 |
||
821
3667bb14aeca
Fix bug debug instance button not visible in PouInstanceVariablesPanel when instance path is too long
laurent
parents:
814
diff
changeset
|
52 |
self.InstanceChoice = wx.ComboBox(self, size=wx.Size(0, 0), style=wx.CB_READONLY) |
814 | 53 |
self.Bind(wx.EVT_COMBOBOX, self.OnInstanceChoiceChanged, |
54 |
self.InstanceChoice) |
|
55 |
self.InstanceChoice.Bind(wx.EVT_LEFT_DOWN, self.OnInstanceChoiceLeftDown) |
|
56 |
||
57 |
self.DebugButton = wx.lib.buttons.GenBitmapButton(self, |
|
58 |
bitmap=GetBitmap("debug_instance"), size=wx.Size(28, 28), style=wx.NO_BORDER) |
|
1082
5a08404d5dda
Fixed bug in PouInstanceVariablesPanel buttons tooltips
Laurent Bessard
parents:
1031
diff
changeset
|
59 |
self.DebugButton.SetToolTipString(_("Debug instance")) |
814 | 60 |
self.Bind(wx.EVT_BUTTON, self.OnDebugButtonClick, |
61 |
self.DebugButton) |
|
62 |
||
63 |
self.VariablesList = CT.CustomTreeCtrl(self, |
|
64 |
style=wx.SUNKEN_BORDER, |
|
65 |
agwStyle=CT.TR_NO_BUTTONS| |
|
66 |
CT.TR_SINGLE| |
|
67 |
CT.TR_HAS_VARIABLE_ROW_HEIGHT| |
|
68 |
CT.TR_HIDE_ROOT| |
|
69 |
CT.TR_NO_LINES| |
|
70 |
getattr(CT, "TR_ALIGN_WINDOWS_RIGHT", CT.TR_ALIGN_WINDOWS)) |
|
71 |
self.VariablesList.SetIndent(0) |
|
72 |
self.VariablesList.SetSpacing(5) |
|
73 |
self.VariablesList.DoSelectItem = lambda *x,**y:True |
|
74 |
self.VariablesList.Bind(CT.EVT_TREE_ITEM_ACTIVATED, |
|
75 |
self.OnVariablesListItemActivated) |
|
76 |
self.VariablesList.Bind(wx.EVT_LEFT_DOWN, self.OnVariablesListLeftDown) |
|
1031
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
77 |
self.VariablesList.Bind(wx.EVT_KEY_DOWN, self.OnVariablesListKeyDown) |
814 | 78 |
|
79 |
buttons_sizer = wx.FlexGridSizer(cols=3, hgap=0, rows=1, vgap=0) |
|
80 |
buttons_sizer.AddWindow(self.ParentButton) |
|
81 |
buttons_sizer.AddWindow(self.InstanceChoice, flag=wx.GROW) |
|
82 |
buttons_sizer.AddWindow(self.DebugButton) |
|
83 |
buttons_sizer.AddGrowableCol(1) |
|
84 |
buttons_sizer.AddGrowableRow(0) |
|
85 |
||
86 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
|
87 |
main_sizer.AddSizer(buttons_sizer, flag=wx.GROW) |
|
88 |
main_sizer.AddWindow(self.VariablesList, flag=wx.GROW) |
|
89 |
main_sizer.AddGrowableCol(0) |
|
90 |
main_sizer.AddGrowableRow(1) |
|
91 |
||
92 |
self.SetSizer(main_sizer) |
|
93 |
||
94 |
self.ParentWindow = window |
|
95 |
self.Controller = controller |
|
96 |
self.Debug = debug |
|
97 |
if not self.Debug: |
|
98 |
self.DebugButton.Hide() |
|
99 |
||
100 |
self.PouTagName = None |
|
101 |
self.PouInfos = None |
|
102 |
self.PouInstance = None |
|
103 |
||
104 |
def __del__(self): |
|
105 |
self.Controller = None |
|
106 |
||
107 |
def SetTreeImageList(self, tree_image_list): |
|
108 |
self.VariablesList.SetImageList(tree_image_list) |
|
109 |
||
110 |
def SetController(self, controller): |
|
111 |
self.Controller = controller |
|
112 |
||
113 |
self.RefreshView() |
|
114 |
||
115 |
def SetPouType(self, tagname, pou_instance=None): |
|
1222
775b48a2be3b
Fixed flickering and lag when refreshing PouInstanceVariablesPanel
Laurent Bessard
parents:
1217
diff
changeset
|
116 |
if self.Controller is not None: |
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
117 |
if tagname == "Project": |
915 | 118 |
config_name = self.Controller.GetProjectMainConfigurationName() |
119 |
if config_name is not None: |
|
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
120 |
tagname = self.Controller.ComputeConfigurationName(config_name) |
915 | 121 |
if pou_instance is not None: |
122 |
self.PouInstance = pou_instance |
|
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
123 |
|
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
124 |
if self.PouTagName != tagname: |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
125 |
self.PouTagName = tagname |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
126 |
self.RefreshView() |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
127 |
else: |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
128 |
self.RefreshInstanceChoice() |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
129 |
else: |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
130 |
self.RefreshView() |
814 | 131 |
|
132 |
def ResetView(self): |
|
133 |
self.Controller = None |
|
134 |
||
135 |
self.PouTagName = None |
|
136 |
self.PouInfos = None |
|
137 |
self.PouInstance = None |
|
138 |
||
139 |
self.RefreshView() |
|
140 |
||
141 |
def RefreshView(self): |
|
1222
775b48a2be3b
Fixed flickering and lag when refreshing PouInstanceVariablesPanel
Laurent Bessard
parents:
1217
diff
changeset
|
142 |
self.Freeze() |
814 | 143 |
self.VariablesList.DeleteAllItems() |
144 |
||
145 |
if self.Controller is not None and self.PouTagName is not None: |
|
146 |
self.PouInfos = self.Controller.GetPouVariables(self.PouTagName, self.Debug) |
|
147 |
else: |
|
148 |
self.PouInfos = None |
|
149 |
if self.PouInfos is not None: |
|
150 |
root = self.VariablesList.AddRoot("") |
|
151 |
for var_infos in self.PouInfos["variables"]: |
|
152 |
if var_infos.get("type", None) is not None: |
|
153 |
text = "%(name)s (%(type)s)" % var_infos |
|
154 |
else: |
|
155 |
text = var_infos["name"] |
|
156 |
||
157 |
panel = wx.Panel(self.VariablesList) |
|
158 |
||
159 |
buttons = [] |
|
160 |
if var_infos["class"] in ITEMS_VARIABLE: |
|
930
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
915
diff
changeset
|
161 |
if (not USE_MPL and var_infos["debug"] and self.Debug and |
814 | 162 |
(self.Controller.IsOfType(var_infos["type"], "ANY_NUM", True) or |
163 |
self.Controller.IsOfType(var_infos["type"], "ANY_BIT", True))): |
|
164 |
graph_button = wx.lib.buttons.GenBitmapButton(panel, |
|
165 |
bitmap=GetBitmap("instance_graph"), |
|
166 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
|
167 |
self.Bind(wx.EVT_BUTTON, self.GenGraphButtonCallback(var_infos), graph_button) |
|
168 |
buttons.append(graph_button) |
|
169 |
elif var_infos["edit"]: |
|
170 |
edit_button = wx.lib.buttons.GenBitmapButton(panel, |
|
171 |
bitmap=GetBitmap("edit"), |
|
172 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
|
173 |
self.Bind(wx.EVT_BUTTON, self.GenEditButtonCallback(var_infos), edit_button) |
|
174 |
buttons.append(edit_button) |
|
175 |
||
176 |
if var_infos["debug"] and self.Debug: |
|
177 |
debug_button = wx.lib.buttons.GenBitmapButton(panel, |
|
178 |
bitmap=GetBitmap("debug_instance"), |
|
179 |
size=wx.Size(28, 28), style=wx.NO_BORDER) |
|
180 |
self.Bind(wx.EVT_BUTTON, self.GenDebugButtonCallback(var_infos), debug_button) |
|
1217
b64dcc1a011f
Fixed bug when moving TextViewer and replacing right click by double click when adding graph in Debug Variable Panel
Laurent Bessard
parents:
1214
diff
changeset
|
181 |
debug_button.Bind(wx.EVT_LEFT_DCLICK, self.GenDebugButtonDClickCallback(var_infos)) |
814 | 182 |
buttons.append(debug_button) |
183 |
||
184 |
button_num = len(buttons) |
|
185 |
if button_num > 0: |
|
186 |
panel.SetSize(wx.Size(button_num * 32, 28)) |
|
187 |
panel.SetBackgroundColour(self.VariablesList.GetBackgroundColour()) |
|
188 |
panel_sizer = wx.BoxSizer(wx.HORIZONTAL) |
|
189 |
panel.SetSizer(panel_sizer) |
|
190 |
||
191 |
for button in buttons: |
|
192 |
panel_sizer.AddWindow(button, 0, border=4, flag=wx.LEFT) |
|
193 |
panel_sizer.Layout() |
|
194 |
||
195 |
else: |
|
196 |
panel.Destroy() |
|
197 |
panel = None |
|
198 |
||
199 |
item = self.VariablesList.AppendItem(root, text, wnd=panel) |
|
200 |
self.VariablesList.SetItemImage(item, self.ParentWindow.GetTreeImage(var_infos["class"])) |
|
201 |
self.VariablesList.SetPyData(item, var_infos) |
|
202 |
||
1238
24577755485d
Fixed bug with InstanceChoice values in PouInstanceVariablesPanel
Laurent Bessard
parents:
1233
diff
changeset
|
203 |
self.RefreshInstanceChoice() |
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
204 |
self.RefreshButtons() |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
205 |
|
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
206 |
self.Thaw() |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
207 |
|
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
208 |
def RefreshInstanceChoice(self): |
1238
24577755485d
Fixed bug with InstanceChoice values in PouInstanceVariablesPanel
Laurent Bessard
parents:
1233
diff
changeset
|
209 |
self.InstanceChoice.Clear() |
24577755485d
Fixed bug with InstanceChoice values in PouInstanceVariablesPanel
Laurent Bessard
parents:
1233
diff
changeset
|
210 |
self.InstanceChoice.SetValue("") |
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
211 |
if self.Controller is not None and self.PouInfos is not None: |
814 | 212 |
instances = self.Controller.SearchPouInstances(self.PouTagName, self.Debug) |
213 |
for instance in instances: |
|
214 |
self.InstanceChoice.Append(instance) |
|
215 |
if len(instances) == 1: |
|
216 |
self.PouInstance = instances[0] |
|
217 |
if self.PouInfos["class"] in [ITEM_CONFIGURATION, ITEM_RESOURCE]: |
|
218 |
self.PouInstance = None |
|
219 |
self.InstanceChoice.SetSelection(0) |
|
220 |
elif self.PouInstance in instances: |
|
221 |
self.InstanceChoice.SetStringSelection(self.PouInstance) |
|
222 |
else: |
|
223 |
self.PouInstance = None |
|
224 |
self.InstanceChoice.SetValue(_("Select an instance")) |
|
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
225 |
|
814 | 226 |
def RefreshButtons(self): |
227 |
enabled = self.InstanceChoice.GetSelection() != -1 |
|
228 |
self.ParentButton.Enable(enabled and self.PouInfos["class"] != ITEM_CONFIGURATION) |
|
229 |
self.DebugButton.Enable(enabled and self.PouInfos["debug"] and self.Debug) |
|
230 |
||
231 |
root = self.VariablesList.GetRootItem() |
|
232 |
if root is not None and root.IsOk(): |
|
233 |
item, item_cookie = self.VariablesList.GetFirstChild(root) |
|
234 |
while item is not None and item.IsOk(): |
|
235 |
panel = self.VariablesList.GetItemWindow(item) |
|
236 |
if panel is not None: |
|
237 |
for child in panel.GetChildren(): |
|
238 |
if child.GetName() != "edit": |
|
239 |
child.Enable(enabled) |
|
240 |
item, item_cookie = self.VariablesList.GetNextChild(root, item_cookie) |
|
241 |
||
242 |
def GenEditButtonCallback(self, infos): |
|
243 |
def EditButtonCallback(event): |
|
244 |
var_class = infos["class"] |
|
245 |
if var_class == ITEM_RESOURCE: |
|
246 |
tagname = self.Controller.ComputeConfigurationResourceName( |
|
247 |
self.InstanceChoice.GetStringSelection(), |
|
248 |
infos["name"]) |
|
826
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
249 |
elif var_class == ITEM_TRANSITION: |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
250 |
tagname = self.Controller.ComputePouTransitionName( |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
251 |
self.PouTagName.split("::")[1], |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
252 |
infos["name"]) |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
253 |
elif var_class == ITEM_ACTION: |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
254 |
tagname = self.Controller.ComputePouActionName( |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
255 |
self.PouTagName.split("::")[1], |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
256 |
infos["name"]) |
814 | 257 |
else: |
258 |
var_class = ITEM_POU |
|
259 |
tagname = self.Controller.ComputePouName(infos["type"]) |
|
260 |
self.ParentWindow.EditProjectElement(var_class, tagname) |
|
261 |
event.Skip() |
|
262 |
return EditButtonCallback |
|
263 |
||
264 |
def GenDebugButtonCallback(self, infos): |
|
265 |
def DebugButtonCallback(event): |
|
266 |
if self.InstanceChoice.GetSelection() != -1: |
|
267 |
var_class = infos["class"] |
|
268 |
var_path = "%s.%s" % (self.InstanceChoice.GetStringSelection(), |
|
269 |
infos["name"]) |
|
270 |
if var_class in ITEMS_VARIABLE: |
|
271 |
self.ParentWindow.AddDebugVariable(var_path, force=True) |
|
826
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
272 |
elif var_class == ITEM_TRANSITION: |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
273 |
self.ParentWindow.OpenDebugViewer( |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
274 |
var_class, |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
275 |
var_path, |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
276 |
self.Controller.ComputePouTransitionName( |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
277 |
self.PouTagName.split("::")[1], |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
278 |
infos["name"])) |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
279 |
elif var_class == ITEM_ACTION: |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
280 |
self.ParentWindow.OpenDebugViewer( |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
281 |
var_class, |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
282 |
var_path, |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
283 |
self.Controller.ComputePouActionName( |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
284 |
self.PouTagName.split("::")[1], |
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
285 |
infos["name"])) |
814 | 286 |
else: |
287 |
self.ParentWindow.OpenDebugViewer( |
|
826
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
288 |
var_class, |
814 | 289 |
var_path, |
290 |
self.Controller.ComputePouName(infos["type"])) |
|
291 |
event.Skip() |
|
292 |
return DebugButtonCallback |
|
293 |
||
1217
b64dcc1a011f
Fixed bug when moving TextViewer and replacing right click by double click when adding graph in Debug Variable Panel
Laurent Bessard
parents:
1214
diff
changeset
|
294 |
def GenDebugButtonDClickCallback(self, infos): |
b64dcc1a011f
Fixed bug when moving TextViewer and replacing right click by double click when adding graph in Debug Variable Panel
Laurent Bessard
parents:
1214
diff
changeset
|
295 |
def DebugButtonDClickCallback(event): |
1214
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1189
diff
changeset
|
296 |
if self.InstanceChoice.GetSelection() != -1: |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1189
diff
changeset
|
297 |
if infos["class"] in ITEMS_VARIABLE: |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1189
diff
changeset
|
298 |
self.ParentWindow.AddDebugVariable( |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1189
diff
changeset
|
299 |
"%s.%s" % (self.InstanceChoice.GetStringSelection(), |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1189
diff
changeset
|
300 |
infos["name"]), |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1189
diff
changeset
|
301 |
force=True, |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1189
diff
changeset
|
302 |
graph=True) |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1189
diff
changeset
|
303 |
event.Skip() |
1217
b64dcc1a011f
Fixed bug when moving TextViewer and replacing right click by double click when adding graph in Debug Variable Panel
Laurent Bessard
parents:
1214
diff
changeset
|
304 |
return DebugButtonDClickCallback |
1214
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1189
diff
changeset
|
305 |
|
814 | 306 |
def GenGraphButtonCallback(self, infos): |
307 |
def GraphButtonCallback(event): |
|
308 |
if self.InstanceChoice.GetSelection() != -1: |
|
309 |
if infos["class"] in ITEMS_VARIABLE: |
|
310 |
var_path = "%s.%s" % (self.InstanceChoice.GetStringSelection(), |
|
311 |
infos["name"]) |
|
885
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
826
diff
changeset
|
312 |
self.ParentWindow.OpenDebugViewer(infos["class"], var_path, infos["type"]) |
814 | 313 |
event.Skip() |
314 |
return GraphButtonCallback |
|
315 |
||
316 |
def ShowInstanceChoicePopup(self): |
|
317 |
self.InstanceChoice.SetFocusFromKbd() |
|
318 |
size = self.InstanceChoice.GetSize() |
|
319 |
event = wx.MouseEvent(wx.EVT_LEFT_DOWN._getEvtType()) |
|
320 |
event.m_x = size.width / 2 |
|
321 |
event.m_y = size.height / 2 |
|
322 |
event.SetEventObject(self.InstanceChoice) |
|
323 |
#event = wx.KeyEvent(wx.EVT_KEY_DOWN._getEvtType()) |
|
324 |
#event.m_keyCode = wx.WXK_SPACE |
|
325 |
self.InstanceChoice.GetEventHandler().ProcessEvent(event) |
|
326 |
||
327 |
def OnParentButtonClick(self, event): |
|
328 |
if self.InstanceChoice.GetSelection() != -1: |
|
329 |
parent_path = self.InstanceChoice.GetStringSelection().rsplit(".", 1)[0] |
|
330 |
tagname = self.Controller.GetPouInstanceTagName(parent_path, self.Debug) |
|
331 |
if tagname is not None: |
|
332 |
wx.CallAfter(self.SetPouType, tagname, parent_path) |
|
333 |
wx.CallAfter(self.ParentWindow.SelectProjectTreeItem, tagname) |
|
334 |
event.Skip() |
|
335 |
||
336 |
def OnInstanceChoiceChanged(self, event): |
|
337 |
self.RefreshButtons() |
|
338 |
event.Skip() |
|
339 |
||
340 |
def OnDebugButtonClick(self, event): |
|
341 |
if self.InstanceChoice.GetSelection() != -1: |
|
342 |
self.ParentWindow.OpenDebugViewer( |
|
343 |
self.PouInfos["class"], |
|
344 |
self.InstanceChoice.GetStringSelection(), |
|
345 |
self.PouTagName) |
|
346 |
event.Skip() |
|
347 |
||
348 |
def OnVariablesListItemActivated(self, event): |
|
1189
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
349 |
selected_item = event.GetItem() |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
350 |
if selected_item is not None and selected_item.IsOk(): |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
351 |
item_infos = self.VariablesList.GetPyData(selected_item) |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
352 |
if item_infos is not None and item_infos["class"] not in ITEMS_VARIABLE: |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
353 |
instance_path = self.InstanceChoice.GetStringSelection() |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
354 |
if item_infos["class"] == ITEM_RESOURCE: |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
355 |
if instance_path != "": |
814 | 356 |
tagname = self.Controller.ComputeConfigurationResourceName( |
357 |
instance_path, |
|
358 |
item_infos["name"]) |
|
359 |
else: |
|
1189
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
360 |
tagname = None |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
361 |
else: |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
362 |
tagname = self.Controller.ComputePouName(item_infos["type"]) |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
363 |
if tagname is not None: |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
364 |
if instance_path != "": |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
365 |
item_path = "%s.%s" % (instance_path, item_infos["name"]) |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
366 |
else: |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
367 |
item_path = None |
814 | 368 |
wx.CallAfter(self.SetPouType, tagname, item_path) |
369 |
wx.CallAfter(self.ParentWindow.SelectProjectTreeItem, tagname) |
|
370 |
event.Skip() |
|
371 |
||
372 |
def OnVariablesListLeftDown(self, event): |
|
373 |
if self.InstanceChoice.GetSelection() == -1: |
|
374 |
wx.CallAfter(self.ShowInstanceChoicePopup) |
|
898
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
375 |
else: |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
376 |
instance_path = self.InstanceChoice.GetStringSelection() |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
377 |
item, flags = self.VariablesList.HitTest(event.GetPosition()) |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
378 |
if item is not None and flags & CT.TREE_HITTEST_ONITEMLABEL: |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
379 |
item_infos = self.VariablesList.GetPyData(item) |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
380 |
if item_infos is not None and item_infos["class"] in ITEMS_VARIABLE: |
1107
9303f6b900fe
Fixed Drag'n dropping from PouInstanceVariablesPanel ensuring DebugVariablePanel is visible before starting drag'n drop
Laurent Bessard
parents:
1082
diff
changeset
|
381 |
self.ParentWindow.EnsureTabVisible( |
9303f6b900fe
Fixed Drag'n dropping from PouInstanceVariablesPanel ensuring DebugVariablePanel is visible before starting drag'n drop
Laurent Bessard
parents:
1082
diff
changeset
|
382 |
self.ParentWindow.DebugVariablePanel) |
898
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
383 |
item_path = "%s.%s" % (instance_path, item_infos["name"]) |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
384 |
data = wx.TextDataObject(str((item_path, "debug"))) |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
385 |
dragSource = wx.DropSource(self.VariablesList) |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
386 |
dragSource.SetData(data) |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
387 |
dragSource.DoDragDrop() |
814 | 388 |
event.Skip() |
1031
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
389 |
|
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
390 |
def OnVariablesListKeyDown(self, event): |
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
391 |
keycode = event.GetKeyCode() |
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
392 |
if keycode != wx.WXK_LEFT: |
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
393 |
event.Skip() |
814 | 394 |
|
395 |
def OnInstanceChoiceLeftDown(self, event): |
|
396 |
event.Skip() |