author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Thu, 21 Apr 2016 19:14:28 +0300 | |
changeset 1497 | 7330c85534ea |
parent 1369 | 9bd4c783c98d |
child 1498 | b11045a2f17c |
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 |
||
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
25 |
from collections import namedtuple |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
26 |
|
814 | 27 |
import wx |
1281 | 28 |
import wx.lib.agw.customtreectrl as CT |
814 | 29 |
import wx.lib.buttons |
30 |
||
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
31 |
# Customize CustomTreeItem for adding icon on item right |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
32 |
CT.GenericTreeItem._rightimages = [] |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
33 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
34 |
def SetRightImages(self, images): |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
35 |
self._rightimages = images |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
36 |
CT.GenericTreeItem.SetRightImages = SetRightImages |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
37 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
38 |
def GetRightImages(self): |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
39 |
return self._rightimages |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
40 |
CT.GenericTreeItem.GetRightImages = GetRightImages |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
41 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
42 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
43 |
class CustomTreeCtrlWithRightImage(CT.CustomTreeCtrl): |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
44 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
45 |
def SetRightImageList(self, imageList): |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
46 |
self._imageListRight = imageList |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
47 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
48 |
def GetLineHeight(self, item): |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
49 |
height = CT.CustomTreeCtrl.GetLineHeight(self, item) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
50 |
rightimages = item.GetRightImages() |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
51 |
if len(rightimages) > 0: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
52 |
r_image_w, r_image_h = self._imageListRight.GetSize(rightimages[0]) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
53 |
return max(height, r_image_h + 8) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
54 |
return height |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
55 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
56 |
def GetItemRightImagesBBox(self, item): |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
57 |
rightimages = item.GetRightImages() |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
58 |
if len(rightimages) > 0: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
59 |
w, h = self.GetClientSize() |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
60 |
total_h = self.GetLineHeight(item) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
61 |
r_image_w, r_image_h = self._imageListRight.GetSize(rightimages[0]) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
62 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
63 |
bbox_width = (r_image_w + 4) * len(rightimages) + 4 |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
64 |
bbox_height = r_image_h + 8 |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
65 |
bbox_x = w - bbox_width |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
66 |
bbox_y = item.GetY() + ((total_h > r_image_h) and [(total_h-r_image_h)/2] or [0])[0] |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
67 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
68 |
return wx.Rect(bbox_x, bbox_y, bbox_width, bbox_height) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
69 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
70 |
return None |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
71 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
72 |
def IsOverItemRightImage(self, item, point): |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
73 |
rightimages = item.GetRightImages() |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
74 |
if len(rightimages) > 0: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
75 |
point = self.CalcUnscrolledPosition(point) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
76 |
r_image_w, r_image_h = self._imageListRight.GetSize(rightimages[0]) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
77 |
images_bbx = self.GetItemRightImagesBBox(item) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
78 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
79 |
rect = wx.Rect(images_bbx.x + 4, images_bbx.y + 4, |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
80 |
r_image_w, r_image_h) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
81 |
for r_image in rightimages: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
82 |
if rect.Inside(point): |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
83 |
return r_image |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
84 |
rect.x += r_image_w + 4 |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
85 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
86 |
return None |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
87 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
88 |
def PaintItem(self, item, dc, level, align): |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
89 |
CT.CustomTreeCtrl.PaintItem(self, item, dc, level, align) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
90 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
91 |
rightimages = item.GetRightImages() |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
92 |
if len(rightimages) > 0: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
93 |
images_bbx = self.GetItemRightImagesBBox(item) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
94 |
r_image_w, r_image_h = self._imageListRight.GetSize(rightimages[0]) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
95 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
96 |
dc.SetBrush(wx.WHITE_BRUSH) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
97 |
dc.SetPen(wx.TRANSPARENT_PEN) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
98 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
99 |
bg_width = (r_image_w + 4) * len(rightimages) + 4 |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
100 |
bg_height = r_image_h + 8 |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
101 |
dc.DrawRectangle(images_bbx.x, images_bbx.y, |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
102 |
images_bbx.width, images_bbx.height) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
103 |
x_pos = images_bbx.x + 4 |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
104 |
for r_image in rightimages: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
105 |
self._imageListRight.Draw( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
106 |
r_image, dc, x_pos, images_bbx.y + 4, |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
107 |
wx.IMAGELIST_DRAW_TRANSPARENT) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
108 |
x_pos += r_image_w + 4 |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
109 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
110 |
_ButtonCallbacks = namedtuple("ButtonCallbacks", ["leftdown", "dclick"]) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
111 |
|
826
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
112 |
from PLCControler import ITEMS_VARIABLE, ITEM_CONFIGURATION, ITEM_RESOURCE, ITEM_POU, ITEM_TRANSITION, ITEM_ACTION |
814 | 113 |
from util.BitmapLibrary import GetBitmap |
114 |
||
115 |
class PouInstanceVariablesPanel(wx.Panel): |
|
1362
077bcba2d485
Cleaner matplotlib import preventing noisy warnings
Edouard Tisserant
parents:
1348
diff
changeset
|
116 |
|
814 | 117 |
def __init__(self, parent, window, controller, debug): |
118 |
wx.Panel.__init__(self, name='PouInstanceTreePanel', |
|
119 |
parent=parent, pos=wx.Point(0, 0), |
|
120 |
size=wx.Size(0, 0), style=wx.TAB_TRAVERSAL) |
|
121 |
||
122 |
self.ParentButton = wx.lib.buttons.GenBitmapButton(self, |
|
123 |
bitmap=GetBitmap("top"), size=wx.Size(28, 28), style=wx.NO_BORDER) |
|
124 |
self.ParentButton.SetToolTipString(_("Parent instance")) |
|
125 |
self.Bind(wx.EVT_BUTTON, self.OnParentButtonClick, |
|
126 |
self.ParentButton) |
|
127 |
||
821
3667bb14aeca
Fix bug debug instance button not visible in PouInstanceVariablesPanel when instance path is too long
laurent
parents:
814
diff
changeset
|
128 |
self.InstanceChoice = wx.ComboBox(self, size=wx.Size(0, 0), style=wx.CB_READONLY) |
814 | 129 |
self.Bind(wx.EVT_COMBOBOX, self.OnInstanceChoiceChanged, |
130 |
self.InstanceChoice) |
|
131 |
||
132 |
self.DebugButton = wx.lib.buttons.GenBitmapButton(self, |
|
133 |
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
|
134 |
self.DebugButton.SetToolTipString(_("Debug instance")) |
814 | 135 |
self.Bind(wx.EVT_BUTTON, self.OnDebugButtonClick, |
136 |
self.DebugButton) |
|
137 |
||
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
138 |
self.VariablesList = CustomTreeCtrlWithRightImage(self, |
814 | 139 |
style=wx.SUNKEN_BORDER, |
140 |
agwStyle=CT.TR_NO_BUTTONS| |
|
141 |
CT.TR_SINGLE| |
|
142 |
CT.TR_HAS_VARIABLE_ROW_HEIGHT| |
|
143 |
CT.TR_HIDE_ROOT| |
|
144 |
CT.TR_NO_LINES| |
|
145 |
getattr(CT, "TR_ALIGN_WINDOWS_RIGHT", CT.TR_ALIGN_WINDOWS)) |
|
146 |
self.VariablesList.SetIndent(0) |
|
147 |
self.VariablesList.SetSpacing(5) |
|
148 |
self.VariablesList.DoSelectItem = lambda *x,**y:True |
|
149 |
self.VariablesList.Bind(CT.EVT_TREE_ITEM_ACTIVATED, |
|
150 |
self.OnVariablesListItemActivated) |
|
151 |
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
|
152 |
self.VariablesList.Bind(wx.EVT_KEY_DOWN, self.OnVariablesListKeyDown) |
814 | 153 |
|
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
154 |
self.TreeRightImageList = wx.ImageList(24, 24) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
155 |
self.EditImage = self.TreeRightImageList.Add(GetBitmap("edit")) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
156 |
self.DebugInstanceImage = self.TreeRightImageList.Add(GetBitmap("debug_instance")) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
157 |
self.VariablesList.SetRightImageList(self.TreeRightImageList) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
158 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
159 |
self.ButtonCallBacks = { |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
160 |
self.EditImage: _ButtonCallbacks( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
161 |
self.EditButtonCallback, None), |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
162 |
self.DebugInstanceImage: _ButtonCallbacks( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
163 |
self.DebugButtonCallback, self.DebugButtonDClickCallback)} |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
164 |
|
814 | 165 |
buttons_sizer = wx.FlexGridSizer(cols=3, hgap=0, rows=1, vgap=0) |
166 |
buttons_sizer.AddWindow(self.ParentButton) |
|
167 |
buttons_sizer.AddWindow(self.InstanceChoice, flag=wx.GROW) |
|
168 |
buttons_sizer.AddWindow(self.DebugButton) |
|
169 |
buttons_sizer.AddGrowableCol(1) |
|
170 |
buttons_sizer.AddGrowableRow(0) |
|
171 |
||
172 |
main_sizer = wx.FlexGridSizer(cols=1, hgap=0, rows=2, vgap=0) |
|
173 |
main_sizer.AddSizer(buttons_sizer, flag=wx.GROW) |
|
174 |
main_sizer.AddWindow(self.VariablesList, flag=wx.GROW) |
|
175 |
main_sizer.AddGrowableCol(0) |
|
176 |
main_sizer.AddGrowableRow(1) |
|
177 |
||
178 |
self.SetSizer(main_sizer) |
|
179 |
||
180 |
self.ParentWindow = window |
|
181 |
self.Controller = controller |
|
182 |
self.Debug = debug |
|
183 |
if not self.Debug: |
|
184 |
self.DebugButton.Hide() |
|
185 |
||
186 |
self.PouTagName = None |
|
187 |
self.PouInfos = None |
|
188 |
self.PouInstance = None |
|
189 |
||
190 |
def __del__(self): |
|
191 |
self.Controller = None |
|
192 |
||
193 |
def SetTreeImageList(self, tree_image_list): |
|
194 |
self.VariablesList.SetImageList(tree_image_list) |
|
195 |
||
196 |
def SetController(self, controller): |
|
197 |
self.Controller = controller |
|
198 |
||
199 |
self.RefreshView() |
|
200 |
||
201 |
def SetPouType(self, tagname, pou_instance=None): |
|
1222
775b48a2be3b
Fixed flickering and lag when refreshing PouInstanceVariablesPanel
Laurent Bessard
parents:
1217
diff
changeset
|
202 |
if self.Controller is not None: |
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
203 |
if tagname == "Project": |
915 | 204 |
config_name = self.Controller.GetProjectMainConfigurationName() |
205 |
if config_name is not None: |
|
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
206 |
tagname = self.Controller.ComputeConfigurationName(config_name) |
915 | 207 |
if pou_instance is not None: |
208 |
self.PouInstance = pou_instance |
|
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
209 |
|
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
210 |
if self.PouTagName != tagname: |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
211 |
self.PouTagName = tagname |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
212 |
self.RefreshView() |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
213 |
else: |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
214 |
self.RefreshInstanceChoice() |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
215 |
else: |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
216 |
self.RefreshView() |
814 | 217 |
|
218 |
def ResetView(self): |
|
219 |
self.Controller = None |
|
220 |
||
221 |
self.PouTagName = None |
|
222 |
self.PouInfos = None |
|
223 |
self.PouInstance = None |
|
224 |
||
225 |
self.RefreshView() |
|
226 |
||
227 |
def RefreshView(self): |
|
1222
775b48a2be3b
Fixed flickering and lag when refreshing PouInstanceVariablesPanel
Laurent Bessard
parents:
1217
diff
changeset
|
228 |
self.Freeze() |
814 | 229 |
self.VariablesList.DeleteAllItems() |
230 |
||
231 |
if self.Controller is not None and self.PouTagName is not None: |
|
232 |
self.PouInfos = self.Controller.GetPouVariables(self.PouTagName, self.Debug) |
|
233 |
else: |
|
234 |
self.PouInfos = None |
|
235 |
if self.PouInfos is not None: |
|
236 |
root = self.VariablesList.AddRoot("") |
|
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
237 |
for var_infos in self.PouInfos.variables: |
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
238 |
if var_infos.type is not None: |
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
239 |
text = "%s (%s)" % (var_infos.name, var_infos.type) |
814 | 240 |
else: |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
241 |
text = var_infos.name |
814 | 242 |
|
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
243 |
right_images = [] |
1364
e9e17d3b2849
Remove old debug panels and viewers not using matplotlib
Laurent Bessard
parents:
1362
diff
changeset
|
244 |
if var_infos.edit: |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
245 |
right_images.append(self.EditImage) |
814 | 246 |
|
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
247 |
if var_infos.debug and self.Debug: |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
248 |
right_images.append(self.DebugInstanceImage) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
249 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
250 |
item = self.VariablesList.AppendItem(root, text) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
251 |
item.SetRightImages(right_images) |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
252 |
self.VariablesList.SetItemImage(item, self.ParentWindow.GetTreeImage(var_infos.var_class)) |
814 | 253 |
self.VariablesList.SetPyData(item, var_infos) |
254 |
||
1238
24577755485d
Fixed bug with InstanceChoice values in PouInstanceVariablesPanel
Laurent Bessard
parents:
1233
diff
changeset
|
255 |
self.RefreshInstanceChoice() |
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
256 |
self.RefreshButtons() |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
257 |
|
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
258 |
self.Thaw() |
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
259 |
|
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
260 |
def RefreshInstanceChoice(self): |
1238
24577755485d
Fixed bug with InstanceChoice values in PouInstanceVariablesPanel
Laurent Bessard
parents:
1233
diff
changeset
|
261 |
self.InstanceChoice.Clear() |
24577755485d
Fixed bug with InstanceChoice values in PouInstanceVariablesPanel
Laurent Bessard
parents:
1233
diff
changeset
|
262 |
self.InstanceChoice.SetValue("") |
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
263 |
if self.Controller is not None and self.PouInfos is not None: |
814 | 264 |
instances = self.Controller.SearchPouInstances(self.PouTagName, self.Debug) |
265 |
for instance in instances: |
|
266 |
self.InstanceChoice.Append(instance) |
|
267 |
if len(instances) == 1: |
|
268 |
self.PouInstance = instances[0] |
|
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
269 |
if self.PouInfos.var_class in [ITEM_CONFIGURATION, ITEM_RESOURCE]: |
814 | 270 |
self.PouInstance = None |
271 |
self.InstanceChoice.SetSelection(0) |
|
272 |
elif self.PouInstance in instances: |
|
273 |
self.InstanceChoice.SetStringSelection(self.PouInstance) |
|
274 |
else: |
|
275 |
self.PouInstance = None |
|
276 |
self.InstanceChoice.SetValue(_("Select an instance")) |
|
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
277 |
|
814 | 278 |
def RefreshButtons(self): |
279 |
enabled = self.InstanceChoice.GetSelection() != -1 |
|
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
280 |
self.ParentButton.Enable(enabled and self.PouInfos.var_class != ITEM_CONFIGURATION) |
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
281 |
self.DebugButton.Enable(enabled and self.PouInfos.debug and self.Debug) |
814 | 282 |
|
283 |
root = self.VariablesList.GetRootItem() |
|
284 |
if root is not None and root.IsOk(): |
|
285 |
item, item_cookie = self.VariablesList.GetFirstChild(root) |
|
286 |
while item is not None and item.IsOk(): |
|
287 |
panel = self.VariablesList.GetItemWindow(item) |
|
288 |
if panel is not None: |
|
289 |
for child in panel.GetChildren(): |
|
290 |
if child.GetName() != "edit": |
|
291 |
child.Enable(enabled) |
|
292 |
item, item_cookie = self.VariablesList.GetNextChild(root, item_cookie) |
|
293 |
||
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
294 |
def EditButtonCallback(self, infos): |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
295 |
var_class = infos.var_class |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
296 |
if var_class == ITEM_RESOURCE: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
297 |
tagname = self.Controller.ComputeConfigurationResourceName( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
298 |
self.InstanceChoice.GetStringSelection(), |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
299 |
infos.name) |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
300 |
elif var_class == ITEM_TRANSITION: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
301 |
tagname = self.Controller.ComputePouTransitionName( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
302 |
self.PouTagName.split("::")[1], |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
303 |
infos.name) |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
304 |
elif var_class == ITEM_ACTION: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
305 |
tagname = self.Controller.ComputePouActionName( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
306 |
self.PouTagName.split("::")[1], |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
307 |
infos.name) |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
308 |
else: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
309 |
var_class = ITEM_POU |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
310 |
tagname = self.Controller.ComputePouName(infos.type) |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
311 |
self.ParentWindow.EditProjectElement(var_class, tagname) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
312 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
313 |
def DebugButtonCallback(self, infos): |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
314 |
if self.InstanceChoice.GetSelection() != -1: |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
315 |
var_class = infos.var_class |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
316 |
var_path = "%s.%s" % (self.InstanceChoice.GetStringSelection(), |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
317 |
infos.name) |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
318 |
if var_class in ITEMS_VARIABLE: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
319 |
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
|
320 |
elif var_class == ITEM_TRANSITION: |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
321 |
self.ParentWindow.OpenDebugViewer( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
322 |
var_class, |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
323 |
var_path, |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
324 |
self.Controller.ComputePouTransitionName( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
325 |
self.PouTagName.split("::")[1], |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
326 |
infos.name)) |
826
098f822ef308
Adding transition and action in list of instances of SFC POU in PouInstanceVariablesPanel
laurent
parents:
821
diff
changeset
|
327 |
elif var_class == ITEM_ACTION: |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
328 |
self.ParentWindow.OpenDebugViewer( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
329 |
var_class, |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
330 |
var_path, |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
331 |
self.Controller.ComputePouActionName( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
332 |
self.PouTagName.split("::")[1], |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
333 |
infos.name)) |
814 | 334 |
else: |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
335 |
self.ParentWindow.OpenDebugViewer( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
336 |
var_class, |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
337 |
var_path, |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
338 |
self.Controller.ComputePouName(infos.type)) |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
339 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
340 |
def DebugButtonDClickCallback(self, infos): |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
341 |
if self.InstanceChoice.GetSelection() != -1: |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
342 |
if infos.var_class in ITEMS_VARIABLE: |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
343 |
self.ParentWindow.AddDebugVariable( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
344 |
"%s.%s" % (self.InstanceChoice.GetStringSelection(), |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
345 |
infos.name), |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
346 |
force=True, |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
347 |
graph=True) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
348 |
|
814 | 349 |
def ShowInstanceChoicePopup(self): |
350 |
self.InstanceChoice.SetFocusFromKbd() |
|
351 |
size = self.InstanceChoice.GetSize() |
|
352 |
event = wx.MouseEvent(wx.EVT_LEFT_DOWN._getEvtType()) |
|
353 |
event.m_x = size.width / 2 |
|
354 |
event.m_y = size.height / 2 |
|
355 |
event.SetEventObject(self.InstanceChoice) |
|
356 |
#event = wx.KeyEvent(wx.EVT_KEY_DOWN._getEvtType()) |
|
357 |
#event.m_keyCode = wx.WXK_SPACE |
|
358 |
self.InstanceChoice.GetEventHandler().ProcessEvent(event) |
|
359 |
||
360 |
def OnParentButtonClick(self, event): |
|
361 |
if self.InstanceChoice.GetSelection() != -1: |
|
362 |
parent_path = self.InstanceChoice.GetStringSelection().rsplit(".", 1)[0] |
|
363 |
tagname = self.Controller.GetPouInstanceTagName(parent_path, self.Debug) |
|
364 |
if tagname is not None: |
|
365 |
wx.CallAfter(self.SetPouType, tagname, parent_path) |
|
366 |
wx.CallAfter(self.ParentWindow.SelectProjectTreeItem, tagname) |
|
367 |
event.Skip() |
|
368 |
||
369 |
def OnInstanceChoiceChanged(self, event): |
|
370 |
self.RefreshButtons() |
|
371 |
event.Skip() |
|
372 |
||
373 |
def OnDebugButtonClick(self, event): |
|
374 |
if self.InstanceChoice.GetSelection() != -1: |
|
375 |
self.ParentWindow.OpenDebugViewer( |
|
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
376 |
self.PouInfos.var_class, |
814 | 377 |
self.InstanceChoice.GetStringSelection(), |
378 |
self.PouTagName) |
|
379 |
event.Skip() |
|
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
380 |
|
814 | 381 |
def OnVariablesListItemActivated(self, event): |
1189
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
382 |
selected_item = event.GetItem() |
93a4431a0cd8
Fixed bug in PouInstanceVariablesPanel, exploring child FunctionBlock variables if no instance selected
Laurent Bessard
parents:
1107
diff
changeset
|
383 |
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
|
384 |
item_infos = self.VariablesList.GetPyData(selected_item) |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
385 |
if item_infos is not None: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
386 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
387 |
item_button = self.VariablesList.IsOverItemRightImage( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
388 |
selected_item, event.GetPoint()) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
389 |
if item_button is not None: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
390 |
callback = self.ButtonCallBacks[item_button].dclick |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
391 |
if callback is not None: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
392 |
callback(item_infos) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
393 |
|
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
394 |
elif item_infos.var_class not in ITEMS_VARIABLE: |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
395 |
instance_path = self.InstanceChoice.GetStringSelection() |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
396 |
if item_infos.var_class == ITEM_RESOURCE: |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
397 |
if instance_path != "": |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
398 |
tagname = self.Controller.ComputeConfigurationResourceName( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
399 |
instance_path, |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
400 |
item_infos.name) |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
401 |
else: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
402 |
tagname = None |
814 | 403 |
else: |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
404 |
tagname = self.Controller.ComputePouName(item_infos.type) |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
405 |
if tagname is not None: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
406 |
if instance_path != "": |
1348
aee0a7eb833a
Fixed pou variables instance information loading stylesheet
Laurent Bessard
parents:
1343
diff
changeset
|
407 |
item_path = "%s.%s" % (instance_path, item_infos.name) |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
408 |
else: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
409 |
item_path = None |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
410 |
self.SetPouType(tagname, item_path) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
411 |
self.ParentWindow.SelectProjectTreeItem(tagname) |
814 | 412 |
event.Skip() |
413 |
||
414 |
def OnVariablesListLeftDown(self, event): |
|
415 |
if self.InstanceChoice.GetSelection() == -1: |
|
416 |
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
|
417 |
else: |
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
418 |
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
|
419 |
item, flags = self.VariablesList.HitTest(event.GetPosition()) |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
420 |
if item is not None: |
898
6b2958f04f30
Adding drag'n drop of debug variable from DebugVariable grid and PouInstance variable list
Laurent Bessard
parents:
885
diff
changeset
|
421 |
item_infos = self.VariablesList.GetPyData(item) |
1343
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
422 |
if item_infos is not None: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
423 |
|
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
424 |
item_button = self.VariablesList.IsOverItemRightImage( |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
425 |
item, event.GetPosition()) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
426 |
if item_button is not None: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
427 |
callback = self.ButtonCallBacks[item_button].leftdown |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
428 |
if callback is not None: |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
429 |
callback(item_infos) |
a76a020b8822
Fixed PouInstanceVariablesPanel, replacing wx controls, too long to create and destroy, by bitmaps directly drawn in panel
Laurent Bessard
parents:
1281
diff
changeset
|
430 |
|
1369
9bd4c783c98d
Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents:
1364
diff
changeset
|
431 |
elif (flags & CT.TREE_HITTEST_ONITEMLABEL and |
9bd4c783c98d
Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents:
1364
diff
changeset
|
432 |
item_infos.var_class in ITEMS_VARIABLE): |
9bd4c783c98d
Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents:
1364
diff
changeset
|
433 |
self.ParentWindow.EnsureTabVisible( |
9bd4c783c98d
Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents:
1364
diff
changeset
|
434 |
self.ParentWindow.DebugVariablePanel) |
9bd4c783c98d
Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents:
1364
diff
changeset
|
435 |
item_path = "%s.%s" % (instance_path, item_infos.name) |
9bd4c783c98d
Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents:
1364
diff
changeset
|
436 |
data = wx.TextDataObject(str((item_path, "debug"))) |
9bd4c783c98d
Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents:
1364
diff
changeset
|
437 |
dragSource = wx.DropSource(self.VariablesList) |
9bd4c783c98d
Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents:
1364
diff
changeset
|
438 |
dragSource.SetData(data) |
9bd4c783c98d
Fixed bug Drag'n drop variables from left panel to debug panel disabled
Laurent Bessard
parents:
1364
diff
changeset
|
439 |
dragSource.DoDragDrop() |
814 | 440 |
event.Skip() |
1031
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
441 |
|
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
442 |
def OnVariablesListKeyDown(self, event): |
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
443 |
keycode = event.GetKeyCode() |
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
444 |
if keycode != wx.WXK_LEFT: |
5743398071eb
Fix bug when pressing left arrow key in PouInstanceVariablesPanel
Laurent Bessard
parents:
930
diff
changeset
|
445 |
event.Skip() |
1277
358db9d64aa1
Fixed refresh bug when activating element in instance variables list
Laurent Bessard
parents:
1238
diff
changeset
|
446 |