author | lbessard |
Wed, 18 Mar 2009 16:09:52 +0100 | |
changeset 329 | 1cf72cb51dc9 |
parent 327 | 7fd5233ce5ce |
child 330 | d803ba077da0 |
permissions | -rw-r--r-- |
0 | 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 |
# |
|
58 | 7 |
#Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
0 | 8 |
# |
9 |
#See COPYING file for copyrights details. |
|
10 |
# |
|
11 |
#This library is free software; you can redistribute it and/or |
|
5 | 12 |
#modify it under the terms of the GNU General Public |
0 | 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 |
|
58 | 19 |
#General Public License for more details. |
0 | 20 |
# |
5 | 21 |
#You should have received a copy of the GNU General Public |
0 | 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 |
|
292 | 26 |
if wx.VERSION >= (2, 8, 0): |
27 |
USE_AUI = True |
|
28 |
else: |
|
29 |
USE_AUI = False |
|
0 | 30 |
|
31 |
from plcopen.structures import * |
|
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
32 |
from PLCControler import ITEM_POU |
27 | 33 |
|
34 |
from Dialogs import * |
|
35 |
||
218 | 36 |
from types import TupleType |
37 |
||
27 | 38 |
SCROLLBAR_UNIT = 10 |
39 |
WINDOW_BORDER = 10 |
|
40 |
SCROLL_ZONE = 10 |
|
0 | 41 |
|
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
42 |
def AppendMenu(parent, help, id, kind, text): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
43 |
if wx.VERSION >= (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
44 |
parent.Append(help=help, id=id, kind=kind, text=text) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
45 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
46 |
parent.Append(helpString=help, id=id, kind=kind, item=text) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
47 |
|
157 | 48 |
if wx.Platform == '__WXMSW__': |
49 |
faces = { 'times': 'Times New Roman', |
|
50 |
'mono' : 'Courier New', |
|
51 |
'helv' : 'Arial', |
|
52 |
'other': 'Comic Sans MS', |
|
158 | 53 |
'size' : 20, |
157 | 54 |
} |
55 |
else: |
|
56 |
faces = { 'times': 'Times', |
|
57 |
'mono' : 'Courier', |
|
58 |
'helv' : 'Helvetica', |
|
59 |
'other': 'new century schoolbook', |
|
158 | 60 |
'size' : 20, |
157 | 61 |
} |
62 |
||
0 | 63 |
#------------------------------------------------------------------------------- |
64 |
# Graphic elements Viewer base class |
|
65 |
#------------------------------------------------------------------------------- |
|
66 |
||
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
67 |
# ID Constants for alignment menu items |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
68 |
[ID_VIEWERALIGNMENTMENUITEMS0, ID_VIEWERALIGNMENTMENUITEMS1, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
69 |
ID_VIEWERALIGNMENTMENUITEMS2, ID_VIEWERALIGNMENTMENUITEMS4, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
70 |
ID_VIEWERALIGNMENTMENUITEMS5, ID_VIEWERALIGNMENTMENUITEMS6, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
71 |
] = [wx.NewId() for _init_coll_AlignmentMenu_Items in range(6)] |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
72 |
|
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
73 |
# ID Constants for contextual menu items |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
74 |
[ID_VIEWERCONTEXTUALMENUITEMS0, ID_VIEWERCONTEXTUALMENUITEMS1, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
75 |
ID_VIEWERCONTEXTUALMENUITEMS2, ID_VIEWERCONTEXTUALMENUITEMS3, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
76 |
ID_VIEWERCONTEXTUALMENUITEMS5, ID_VIEWERCONTEXTUALMENUITEMS6, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
77 |
ID_VIEWERCONTEXTUALMENUITEMS8, ID_VIEWERCONTEXTUALMENUITEMS9, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
78 |
ID_VIEWERCONTEXTUALMENUITEMS11, ID_VIEWERCONTEXTUALMENUITEMS12, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
79 |
ID_VIEWERCONTEXTUALMENUITEMS14, ID_VIEWERCONTEXTUALMENUITEMS16, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
80 |
ID_VIEWERCONTEXTUALMENUITEMS17, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
81 |
] = [wx.NewId() for _init_coll_ContextualMenu_Items in range(13)] |
0 | 82 |
|
83 |
||
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
84 |
class ViewerDropTarget(wx.TextDropTarget): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
85 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
86 |
def __init__(self, parent): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
87 |
wx.TextDropTarget.__init__(self) |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
88 |
self.ParentWindow = parent |
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
89 |
|
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
90 |
def OnDropText(self, x, y, data): |
108 | 91 |
x, y = self.ParentWindow.CalcUnscrolledPosition(x, y) |
323 | 92 |
x = int(x / self.ParentWindow.ViewScale[0]) |
93 |
y = int(y / self.ParentWindow.ViewScale[1]) |
|
145 | 94 |
scaling = self.ParentWindow.Scaling |
218 | 95 |
message = None |
96 |
try: |
|
97 |
values = eval(data) |
|
98 |
except: |
|
99 |
message = "Invalid value \"%s\" for viewer block"%data |
|
100 |
values = None |
|
101 |
if not isinstance(values, TupleType): |
|
102 |
message = "Invalid value \"%s\" for viewer block"%data |
|
103 |
values = None |
|
104 |
if values is not None: |
|
249 | 105 |
if values[1] == "debug": |
106 |
pass |
|
107 |
elif values[1] == "program": |
|
218 | 108 |
message = "Programs can't be used by other POUs!" |
109 |
elif values[1] in ["function", "functionBlock", "program"]: |
|
249 | 110 |
name, type = self.ParentWindow.Controler.GetEditedElementType(self.ParentWindow.GetTagName(), self.ParentWindow.Debug) |
253 | 111 |
words = self.ParentWindow.TagName.split("::") |
218 | 112 |
if name == values[0]: |
113 |
message = "\"%s\" can't use itself!"%name |
|
114 |
elif type == "function" and values[1] != "function": |
|
253 | 115 |
message = "Function Blocks can't be used in Functions!" |
116 |
elif words[0] == "T" and values[1] != "function": |
|
117 |
message = "Function Blocks can't be used in Transitions!" |
|
249 | 118 |
elif self.ParentWindow.Controler.PouIsUsedBy(name, values[0], self.ParentWindow.Debug): |
218 | 119 |
message = "\"%s\" is already used by \"%s\"!"%(name, values[0]) |
195
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
120 |
else: |
218 | 121 |
blockname = values[2] |
239
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
122 |
if len(values) > 3: |
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
123 |
blockinputs = values[3] |
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
124 |
else: |
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
125 |
blockinputs = None |
218 | 126 |
if values[1] != "function" and blockname == "": |
239
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
127 |
dialog = wx.TextEntryDialog(self.ParentWindow.ParentWindow, "Block name", "Please enter a block name", "", wx.OK|wx.CANCEL|wx.CENTRE) |
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
128 |
if dialog.ShowModal() == wx.ID_OK: |
218 | 129 |
blockname = dialog.GetValue() |
239
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
130 |
else: |
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
131 |
return |
218 | 132 |
dialog.Destroy() |
249 | 133 |
if blockname.upper() in [name.upper() for name in self.ParentWindow.Controler.GetProjectPouNames(self.ParentWindow.Debug)]: |
218 | 134 |
message = "\"%s\" pou already exists!"%blockname |
249 | 135 |
elif blockname.upper() in [name.upper() for name in self.ParentWindow.Controler.GetEditedElementVariables(self.ParentWindow.GetTagName(), self.ParentWindow.Debug)]: |
218 | 136 |
message = "\"%s\" element for this pou already exists!"%blockname |
137 |
else: |
|
138 |
id = self.ParentWindow.GetNewId() |
|
239
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
139 |
block = FBD_Block(self.ParentWindow, values[0], blockname, id, inputs = blockinputs) |
218 | 140 |
width, height = block.GetMinSize() |
141 |
if scaling is not None: |
|
142 |
x = round(float(x) / float(scaling[0])) * scaling[0] |
|
143 |
y = round(float(y) / float(scaling[1])) * scaling[1] |
|
144 |
width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0] |
|
145 |
height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1] |
|
146 |
block.SetPosition(x, y) |
|
147 |
block.SetSize(width, height) |
|
148 |
self.ParentWindow.AddBlock(block) |
|
149 |
self.ParentWindow.Controler.AddEditedElementBlock(self.ParentWindow.GetTagName(), id, values[0], blockname) |
|
150 |
self.ParentWindow.RefreshBlockModel(block) |
|
151 |
self.ParentWindow.RefreshBuffer() |
|
152 |
self.ParentWindow.RefreshScrollBars() |
|
249 | 153 |
self.ParentWindow.RefreshVisibleElements() |
218 | 154 |
self.ParentWindow.ParentWindow.RefreshVariablePanel(self.ParentWindow.GetTagName()) |
155 |
self.ParentWindow.Refresh(False) |
|
156 |
elif values[1] != "location": |
|
297
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
157 |
tagname = self.ParentWindow.GetTagName() |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
158 |
if values[3] == tagname: |
218 | 159 |
if values[1] == "Output": |
297
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
160 |
var_class = OUTPUT |
218 | 161 |
elif values[1] == "InOut": |
297
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
162 |
var_class = INPUT |
218 | 163 |
else: |
297
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
164 |
var_class = INPUT |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
165 |
tree = dict([(var["Name"], var["Tree"]) for var in self.ParentWindow.Controler.GetEditedElementInterfaceVars(tagname, self.ParentWindow.Debug)]).get(values[0], None) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
166 |
if tree is not None: |
302
43e10dccc16a
Bug while drag and drop simple variables poping menu fixed
lbessard
parents:
299
diff
changeset
|
167 |
if len(tree[0]) > 0: |
297
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
168 |
menu = wx.Menu(title='') |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
169 |
self.GenerateTreeMenu(x, y, scaling, menu, "", var_class, [(values[0], values[2], tree)]) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
170 |
self.ParentWindow.PopupMenuXY(menu) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
171 |
else: |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
172 |
self.AddParentVariableBlock(x, y, scaling, var_class, values[0], values[2]) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
173 |
else: |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
174 |
message = "Unknown variable \"%s\" this POU!" % values[0] |
121 | 175 |
else: |
218 | 176 |
message = "Variable don't belong to this POU!" |
249 | 177 |
if message is not None: |
178 |
wx.CallAfter(self.ShowMessage, message) |
|
218 | 179 |
|
297
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
180 |
def GenerateTreeMenu(self, x, y, scaling, menu, base_path, var_class, tree): |
299
15669fe26e56
Adding support for generating real array dimension in variable blocks
lbessard
parents:
297
diff
changeset
|
181 |
for child_name, child_type, (child_tree, child_dimensions) in tree: |
297
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
182 |
if base_path: |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
183 |
child_path = "%s.%s" % (base_path, child_name) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
184 |
else: |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
185 |
child_path = child_name |
299
15669fe26e56
Adding support for generating real array dimension in variable blocks
lbessard
parents:
297
diff
changeset
|
186 |
if len(child_dimensions) > 0: |
15669fe26e56
Adding support for generating real array dimension in variable blocks
lbessard
parents:
297
diff
changeset
|
187 |
child_path += "[%s]" % ",".join([str(dimension[0]) for dimension in child_dimensions]) |
297
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
188 |
child_name += "[]" |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
189 |
new_id = wx.NewId() |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
190 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=child_name) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
191 |
self.ParentWindow.Bind(wx.EVT_MENU, self.GetAddVariableBlockFunction(x, y, scaling, var_class, child_path, child_type), id=new_id) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
192 |
if len(child_tree) > 0: |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
193 |
new_id = wx.NewId() |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
194 |
child_menu = wx.Menu(title='') |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
195 |
self.GenerateTreeMenu(x, y, scaling, child_menu, child_path, var_class, child_tree) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
196 |
menu.AppendMenu(new_id, "%s." % child_name, child_menu) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
197 |
|
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
198 |
def GetAddVariableBlockFunction(self, x, y, scaling, var_class, var_name, var_type): |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
199 |
def AddVariableFunction(event): |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
200 |
self.AddParentVariableBlock(x, y, scaling, var_class, var_name, var_type) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
201 |
return AddVariableFunction |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
202 |
|
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
203 |
def AddParentVariableBlock(self, x, y, scaling, var_class, var_name, var_type): |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
204 |
id = self.ParentWindow.GetNewId() |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
205 |
variable = FBD_Variable(self.ParentWindow, var_class, var_name, var_type, id) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
206 |
width, height = variable.GetMinSize() |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
207 |
if scaling is not None: |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
208 |
x = round(float(x) / float(scaling[0])) * scaling[0] |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
209 |
y = round(float(y) / float(scaling[1])) * scaling[1] |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
210 |
width = round(float(width) / float(scaling[0]) + 0.5) * scaling[0] |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
211 |
height = round(float(height) / float(scaling[1]) + 0.5) * scaling[1] |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
212 |
variable.SetPosition(x, y) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
213 |
variable.SetSize(width, height) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
214 |
self.ParentWindow.AddBlock(variable) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
215 |
self.ParentWindow.Controler.AddEditedElementVariable(self.ParentWindow.GetTagName(), id, var_class) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
216 |
self.ParentWindow.RefreshVariableModel(variable) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
217 |
self.ParentWindow.RefreshBuffer() |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
218 |
self.ParentWindow.RefreshScrollBars() |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
219 |
self.ParentWindow.RefreshVisibleElements() |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
220 |
self.ParentWindow.Refresh(False) |
e837b67cb184
Adding help menu for inserting complex variable in graphical viewer
lbessard
parents:
292
diff
changeset
|
221 |
|
218 | 222 |
def ShowMessage(self, message): |
249 | 223 |
message = wx.MessageDialog(self.ParentWindow, message, "Error", wx.OK|wx.ICON_ERROR) |
224 |
message.ShowModal() |
|
225 |
message.Destroy() |
|
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
226 |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
227 |
|
0 | 228 |
""" |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
229 |
Class that implements a Viewer based on a wx.ScrolledWindow for drawing and |
0 | 230 |
manipulating graphic elements |
231 |
""" |
|
232 |
||
233 |
class Viewer(wx.ScrolledWindow): |
|
234 |
||
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
235 |
if wx.VERSION < (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
236 |
def Bind(self, event, function, id = None): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
237 |
if id is not None: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
238 |
event(self, id, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
239 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
240 |
event(self, function) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
241 |
|
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
242 |
# Create Alignment Menu items |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
243 |
def _init_coll_AlignmentMenu_Items(self, parent): |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
244 |
# Create menu items |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
245 |
AppendMenu(parent, help='', id=ID_VIEWERALIGNMENTMENUITEMS0, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
246 |
kind=wx.ITEM_NORMAL, text=u'Left') |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
247 |
AppendMenu(parent, help='', id=ID_VIEWERALIGNMENTMENUITEMS1, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
248 |
kind=wx.ITEM_NORMAL, text=u'Center') |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
249 |
AppendMenu(parent, help='', id=ID_VIEWERALIGNMENTMENUITEMS2, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
250 |
kind=wx.ITEM_NORMAL, text=u'Right') |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
251 |
parent.AppendSeparator() |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
252 |
AppendMenu(parent, help='', id=ID_VIEWERALIGNMENTMENUITEMS4, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
253 |
kind=wx.ITEM_NORMAL, text=u'Top') |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
254 |
AppendMenu(parent, help='', id=ID_VIEWERALIGNMENTMENUITEMS5, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
255 |
kind=wx.ITEM_NORMAL, text=u'Middle') |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
256 |
AppendMenu(parent, help='', id=ID_VIEWERALIGNMENTMENUITEMS6, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
257 |
kind=wx.ITEM_NORMAL, text=u'Bottom') |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
258 |
# Link menu event to corresponding called functions |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
259 |
self.Bind(wx.EVT_MENU, self.OnAlignLeftMenu, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
260 |
id=ID_VIEWERALIGNMENTMENUITEMS0) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
261 |
self.Bind(wx.EVT_MENU, self.OnAlignCenterMenu, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
262 |
id=ID_VIEWERALIGNMENTMENUITEMS1) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
263 |
self.Bind(wx.EVT_MENU, self.OnAlignRightMenu, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
264 |
id=ID_VIEWERALIGNMENTMENUITEMS2) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
265 |
self.Bind(wx.EVT_MENU, self.OnAlignTopMenu, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
266 |
id=ID_VIEWERALIGNMENTMENUITEMS4) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
267 |
self.Bind(wx.EVT_MENU, self.OnAlignMiddleMenu, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
268 |
id=ID_VIEWERALIGNMENTMENUITEMS5) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
269 |
self.Bind(wx.EVT_MENU, self.OnAlignBottomMenu, |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
270 |
id=ID_VIEWERALIGNMENTMENUITEMS6) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
271 |
|
0 | 272 |
# Create Contextual Menu items |
273 |
def _init_coll_ContextualMenu_Items(self, parent): |
|
274 |
# Create menu items |
|
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
275 |
AppendMenu(parent, help='', id=ID_VIEWERCONTEXTUALMENUITEMS0, |
0 | 276 |
kind=wx.ITEM_RADIO, text=u'No Modifier') |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
277 |
AppendMenu(parent, help='', id=ID_VIEWERCONTEXTUALMENUITEMS1, |
0 | 278 |
kind=wx.ITEM_RADIO, text=u'Negated') |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
279 |
AppendMenu(parent, help='', id=ID_VIEWERCONTEXTUALMENUITEMS2, |
0 | 280 |
kind=wx.ITEM_RADIO, text=u'Rising Edge') |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
281 |
AppendMenu(parent, help='', id=ID_VIEWERCONTEXTUALMENUITEMS3, |
0 | 282 |
kind=wx.ITEM_RADIO, text=u'Falling Edge') |
283 |
parent.AppendSeparator() |
|
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
284 |
AppendMenu(parent, help='', id=ID_VIEWERCONTEXTUALMENUITEMS5, |
0 | 285 |
kind=wx.ITEM_NORMAL, text=u'Add Wire Segment') |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
286 |
AppendMenu(parent, help='', id=ID_VIEWERCONTEXTUALMENUITEMS6, |
0 | 287 |
kind=wx.ITEM_NORMAL, text=u'Delete Wire Segment') |
288 |
parent.AppendSeparator() |
|
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
289 |
AppendMenu(parent, help='', id=ID_VIEWERCONTEXTUALMENUITEMS8, |
0 | 290 |
kind=wx.ITEM_NORMAL, text=u'Add Divergence Branch') |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
291 |
AppendMenu(parent, help='', id=ID_VIEWERCONTEXTUALMENUITEMS9, |
0 | 292 |
kind=wx.ITEM_NORMAL, text=u'Delete Divergence Branch') |
293 |
parent.AppendSeparator() |
|
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
294 |
AppendMenu(parent, help='', id=ID_VIEWERCONTEXTUALMENUITEMS11, |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
295 |
kind=wx.ITEM_NORMAL, text=u'Clear Execution Order') |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
296 |
AppendMenu(parent, help='', id=ID_VIEWERCONTEXTUALMENUITEMS12, |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
297 |
kind=wx.ITEM_NORMAL, text=u'Reset Execution Order') |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
298 |
parent.AppendSeparator() |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
299 |
parent.AppendMenu(ID_VIEWERCONTEXTUALMENUITEMS14, "Alignment", self.AlignmentMenu) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
300 |
parent.AppendSeparator() |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
301 |
AppendMenu(parent, help='', id=ID_VIEWERCONTEXTUALMENUITEMS16, |
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
302 |
kind=wx.ITEM_NORMAL, text=u'Edit Block') |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
303 |
AppendMenu(parent, help='', id=ID_VIEWERCONTEXTUALMENUITEMS17, |
0 | 304 |
kind=wx.ITEM_NORMAL, text=u'Delete') |
305 |
# Link menu event to corresponding called functions |
|
306 |
self.Bind(wx.EVT_MENU, self.OnNoModifierMenu, |
|
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
307 |
id=ID_VIEWERCONTEXTUALMENUITEMS0) |
0 | 308 |
self.Bind(wx.EVT_MENU, self.OnNegatedMenu, |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
309 |
id=ID_VIEWERCONTEXTUALMENUITEMS1) |
0 | 310 |
self.Bind(wx.EVT_MENU, self.OnRisingEdgeMenu, |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
311 |
id=ID_VIEWERCONTEXTUALMENUITEMS2) |
0 | 312 |
self.Bind(wx.EVT_MENU, self.OnFallingEdgeMenu, |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
313 |
id=ID_VIEWERCONTEXTUALMENUITEMS3) |
0 | 314 |
self.Bind(wx.EVT_MENU, self.OnAddSegmentMenu, |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
315 |
id=ID_VIEWERCONTEXTUALMENUITEMS5) |
0 | 316 |
self.Bind(wx.EVT_MENU, self.OnDeleteSegmentMenu, |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
317 |
id=ID_VIEWERCONTEXTUALMENUITEMS6) |
0 | 318 |
self.Bind(wx.EVT_MENU, self.OnAddBranchMenu, |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
319 |
id=ID_VIEWERCONTEXTUALMENUITEMS8) |
0 | 320 |
self.Bind(wx.EVT_MENU, self.OnDeleteBranchMenu, |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
321 |
id=ID_VIEWERCONTEXTUALMENUITEMS9) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
322 |
self.Bind(wx.EVT_MENU, self.OnClearExecutionOrderMenu, |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
323 |
id=ID_VIEWERCONTEXTUALMENUITEMS11) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
324 |
self.Bind(wx.EVT_MENU, self.OnResetExecutionOrderMenu, |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
325 |
id=ID_VIEWERCONTEXTUALMENUITEMS12) |
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
326 |
self.Bind(wx.EVT_MENU, self.OnEditBlockMenu, |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
327 |
id=ID_VIEWERCONTEXTUALMENUITEMS16) |
0 | 328 |
self.Bind(wx.EVT_MENU, self.OnDeleteMenu, |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
329 |
id=ID_VIEWERCONTEXTUALMENUITEMS17) |
0 | 330 |
|
331 |
# Create and initialize Contextual Menu |
|
332 |
def _init_menus(self): |
|
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
333 |
self.AlignmentMenu = wx.Menu(title='') |
0 | 334 |
self.ContextualMenu = wx.Menu(title='') |
335 |
||
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
336 |
self._init_coll_AlignmentMenu_Items(self.AlignmentMenu) |
0 | 337 |
self._init_coll_ContextualMenu_Items(self.ContextualMenu) |
338 |
||
339 |
# Create a new Viewer |
|
249 | 340 |
def __init__(self, parent, tagname, window, controler, debug = False, instancepath = ""): |
80 | 341 |
wx.ScrolledWindow.__init__(self, parent, pos=wx.Point(0, 0), size=wx.Size(0, 0), |
319 | 342 |
style=wx.HSCROLL | wx.VSCROLL | wx.ALWAYS_SHOW_SB) |
0 | 343 |
self._init_menus() |
344 |
# Adding a rubberband to Viewer |
|
345 |
self.rubberBand = RubberBand(drawingSurface=self) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
346 |
self.SetBackgroundColour(wx.Colour(255,255,255)) |
224
e5bf78b847e1
Bug with AutoBufferedPaintDC and Background style fixed
lbessard
parents:
222
diff
changeset
|
347 |
self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) |
0 | 348 |
self.ResetView() |
349 |
self.Scaling = None |
|
350 |
self.DrawGrid = True |
|
145 | 351 |
self.GridBrush = wx.TRANSPARENT_BRUSH |
213 | 352 |
self.PageSize = None |
323 | 353 |
self.ViewScale = (1.0, 1.0) |
213 | 354 |
self.PagePen = wx.TRANSPARENT_PEN |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
355 |
self.DrawingWire = False |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
356 |
self.current_id = 0 |
121 | 357 |
self.TagName = tagname |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
358 |
self.Errors = [] |
249 | 359 |
self.Debug = debug |
360 |
self.InstancePath = instancepath |
|
319 | 361 |
self.StartMousePos = None |
362 |
self.StartScreenPos = None |
|
0 | 363 |
|
42 | 364 |
# Initialize Block, Wire and Comment numbers |
365 |
self.block_id = self.wire_id = self.comment_id = 0 |
|
366 |
||
0 | 367 |
# Initialize Viewer mode to Selection mode |
368 |
self.Mode = MODE_SELECTION |
|
3
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
369 |
self.SavedMode = False |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
370 |
self.CurrentLanguage = "FBD" |
0 | 371 |
|
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
372 |
self.ParentWindow = window |
0 | 373 |
self.Controler = controler |
374 |
||
249 | 375 |
if not self.Debug: |
376 |
self.SetDropTarget(ViewerDropTarget(self)) |
|
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
377 |
|
156 | 378 |
dc = wx.ClientDC(self) |
213 | 379 |
font = wx.Font(faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName = faces["mono"]) |
165 | 380 |
dc.SetFont(font) |
158 | 381 |
width, height = dc.GetTextExtent("ABCDEFGHIJKLMNOPQRSTUVWXYZ") |
382 |
while width > 260: |
|
157 | 383 |
faces["size"] -= 1 |
213 | 384 |
font = wx.Font(faces["size"], wx.SWISS, wx.NORMAL, wx.NORMAL, faceName = faces["mono"]) |
165 | 385 |
dc.SetFont(font) |
158 | 386 |
width, height = dc.GetTextExtent("ABCDEFGHIJKLMNOPQRSTUVWXYZ") |
165 | 387 |
self.SetFont(font) |
156 | 388 |
|
249 | 389 |
self.ResetView() |
390 |
||
0 | 391 |
# Link Viewer event to corresponding methods |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
392 |
self.Bind(wx.EVT_PAINT, self.OnPaint) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
393 |
self.Bind(wx.EVT_LEFT_DOWN, self.OnViewerLeftDown) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
394 |
self.Bind(wx.EVT_LEFT_UP, self.OnViewerLeftUp) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
395 |
self.Bind(wx.EVT_LEFT_DCLICK, self.OnViewerLeftDClick) |
145 | 396 |
self.Bind(wx.EVT_RIGHT_DOWN, self.OnViewerRightDown) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
397 |
self.Bind(wx.EVT_RIGHT_UP, self.OnViewerRightUp) |
319 | 398 |
self.Bind(wx.EVT_MIDDLE_DOWN, self.OnViewerMiddleDown) |
399 |
self.Bind(wx.EVT_MIDDLE_UP, self.OnViewerMiddleUp) |
|
140
06d28f03f6f4
Adding highlighting on group or element when mouse is over
lbessard
parents:
138
diff
changeset
|
400 |
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeaveViewer) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
401 |
self.Bind(wx.EVT_MOTION, self.OnViewerMotion) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
402 |
self.Bind(wx.EVT_CHAR, self.OnChar) |
249 | 403 |
self.Bind(wx.EVT_SCROLLWIN, self.OnScrollWindow) |
319 | 404 |
self.Bind(wx.EVT_SCROLLWIN_THUMBRELEASE, self.OnScrollStop) |
253 | 405 |
self.Bind(wx.EVT_MOUSEWHEEL, self.OnMouseWheelWindow) |
144 | 406 |
self.Bind(wx.EVT_SIZE, self.OnMoveWindow) |
407 |
||
408 |
def GetScrolledRect(self, rect): |
|
323 | 409 |
rect.x, rect.y = self.CalcScrolledPosition(int(rect.x * self.ViewScale[0]), |
410 |
int(rect.y * self.ViewScale[1])) |
|
411 |
rect.width = int(rect.width * self.ViewScale[0]) + 2 |
|
412 |
rect.height = int(rect.height * self.ViewScale[1]) + 2 |
|
144 | 413 |
return rect |
0 | 414 |
|
145 | 415 |
def GetScaling(self): |
416 |
return self.Scaling |
|
417 |
||
121 | 418 |
def SetTagName(self, tagname): |
419 |
self.TagName = tagname |
|
420 |
||
421 |
def GetTagName(self): |
|
422 |
return self.TagName |
|
423 |
||
249 | 424 |
def GetInstancePath(self): |
425 |
return self.InstancePath |
|
426 |
||
121 | 427 |
def IsViewing(self, tagname): |
249 | 428 |
if self.Debug: |
429 |
return self.InstancePath == tagname |
|
430 |
else: |
|
431 |
return self.TagName == tagname |
|
121 | 432 |
|
0 | 433 |
# Returns a new id |
434 |
def GetNewId(self): |
|
435 |
self.current_id += 1 |
|
436 |
return self.current_id |
|
437 |
||
438 |
# Destructor |
|
439 |
def __del__(self): |
|
249 | 440 |
self.Flush() |
0 | 441 |
self.ResetView() |
323 | 442 |
|
443 |
def SetScale(self, scalex, scaley): |
|
444 |
self.ViewScale = (scalex, scaley) |
|
445 |
self.RefreshScaling() |
|
0 | 446 |
|
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
447 |
def GetLogicalDC(self, buffered=False): |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
448 |
if buffered: |
213 | 449 |
dc = wx.AutoBufferedPaintDC(self) |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
450 |
else: |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
451 |
dc = wx.ClientDC(self) |
165 | 452 |
dc.SetFont(self.GetFont()) |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
453 |
if wx.VERSION >= (2, 6, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
454 |
self.DoPrepareDC(dc) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
455 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
456 |
self.PrepareDC(dc) |
323 | 457 |
dc.SetUserScale(self.ViewScale[0], self.ViewScale[1]) |
27 | 458 |
return dc |
459 |
||
253 | 460 |
def GetMiniFont(self): |
461 |
font = self.GetFont() |
|
462 |
return wx.Font(font.GetPointSize() * 0.75, wx.SWISS, wx.NORMAL, wx.NORMAL, faceName = faces["helv"]) |
|
463 |
||
0 | 464 |
#------------------------------------------------------------------------------- |
42 | 465 |
# Element management functions |
466 |
#------------------------------------------------------------------------------- |
|
467 |
||
468 |
def AddBlock(self, block): |
|
469 |
self.block_id += 1 |
|
470 |
self.Blocks[block] = self.block_id |
|
471 |
||
472 |
def AddWire(self, wire): |
|
473 |
self.wire_id += 1 |
|
474 |
self.Wires[wire] = self.wire_id |
|
475 |
||
476 |
def AddComment(self, comment): |
|
477 |
self.comment_id += 1 |
|
478 |
self.Comments[comment] = self.comment_id |
|
479 |
||
480 |
def IsBlock(self, block): |
|
481 |
return self.Blocks.get(block, False) |
|
482 |
||
483 |
def IsWire(self, wire): |
|
484 |
return self.Wires.get(wire, False) |
|
485 |
||
486 |
def IsComment(self, comment): |
|
487 |
return self.Comments.get(comment, False) |
|
488 |
||
489 |
def RemoveBlock(self, block): |
|
490 |
self.Blocks.pop(block) |
|
491 |
||
492 |
def RemoveWire(self, wire): |
|
493 |
self.Wires.pop(wire) |
|
494 |
||
495 |
def RemoveComment(self, comment): |
|
496 |
self.Comments.pop(comment) |
|
497 |
||
498 |
def GetElements(self, sort_blocks=False, sort_wires=False, sort_comments=False): |
|
499 |
blocks = self.Blocks.keys() |
|
500 |
wires = self.Wires.keys() |
|
501 |
comments = self.Comments.keys() |
|
502 |
if sort_blocks: |
|
283 | 503 |
blocks.sort(lambda x, y: cmp(self.Blocks[x], self.Blocks[y])) |
42 | 504 |
if sort_wires: |
283 | 505 |
wires.sort(lambda x, y: cmp(self.Wires[x], self.Wires[y])) |
42 | 506 |
if sort_comments: |
283 | 507 |
comments.sort(lambda x, y: cmp(self.Comments[x], self.Comments[y])) |
42 | 508 |
return blocks + wires + comments |
509 |
||
249 | 510 |
def RefreshVisibleElements(self, xp = None, yp = None): |
511 |
x, y = self.CalcUnscrolledPosition(0, 0) |
|
512 |
if xp is not None: |
|
513 |
x = xp * self.GetScrollPixelsPerUnit()[0] |
|
514 |
if yp is not None: |
|
515 |
y = yp * self.GetScrollPixelsPerUnit()[1] |
|
516 |
width, height = self.GetClientSize() |
|
323 | 517 |
screen = wx.Rect(int(x / self.ViewScale[0]), int(y / self.ViewScale[1]), |
518 |
int(width / self.ViewScale[0]), int(height / self.ViewScale[1])) |
|
249 | 519 |
for comment in self.Comments: |
520 |
comment.TestVisible(screen) |
|
521 |
for wire in self.Wires: |
|
522 |
wire.TestVisible(screen) |
|
523 |
for block in self.Blocks: |
|
524 |
block.TestVisible(screen) |
|
525 |
||
42 | 526 |
#------------------------------------------------------------------------------- |
0 | 527 |
# Reset functions |
528 |
#------------------------------------------------------------------------------- |
|
529 |
||
530 |
# Resets Viewer lists |
|
531 |
def ResetView(self): |
|
42 | 532 |
self.Blocks = {} |
533 |
self.Wires = {} |
|
534 |
self.Comments = {} |
|
249 | 535 |
self.Subscribed = {} |
0 | 536 |
self.SelectedElement = None |
140
06d28f03f6f4
Adding highlighting on group or element when mouse is over
lbessard
parents:
138
diff
changeset
|
537 |
self.HighlightedElement = None |
0 | 538 |
|
249 | 539 |
def Flush(self): |
264 | 540 |
for element, iec_path in self.Subscribed.iteritems(): |
541 |
self.Controler.UnsubscribeDebugIECVariable(iec_path, element) |
|
249 | 542 |
for block in self.Blocks: |
543 |
block.Flush() |
|
544 |
||
47
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
545 |
# Remove all elements |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
546 |
def CleanView(self): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
547 |
for block in self.Blocks.keys(): |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
548 |
block.Clean() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
549 |
self.ResetView() |
2b2f8d88e6d3
Interface changed to show pou interface at the bottom of the window
lbessard
parents:
45
diff
changeset
|
550 |
|
0 | 551 |
# Changes Viewer mode |
552 |
def SetMode(self, mode): |
|
3
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
553 |
if self.Mode != mode or mode == MODE_SELECTION: |
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
554 |
self.Mode = mode |
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
555 |
self.SavedMode = False |
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
556 |
else: |
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
557 |
self.SavedMode = True |
0 | 558 |
# Reset selection |
3
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
559 |
if self.Mode != MODE_SELECTION and self.SelectedElement: |
0 | 560 |
self.SelectedElement.SetSelected(False) |
561 |
self.SelectedElement = None |
|
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
562 |
|
27 | 563 |
# Return current drawing mode |
564 |
def GetDrawingMode(self): |
|
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
565 |
return self.ParentWindow.GetDrawingMode() |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
566 |
|
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
567 |
# Buffer the last model state |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
568 |
def RefreshBuffer(self): |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
569 |
self.Controler.BufferProject() |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
570 |
self.ParentWindow.RefreshTitle() |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
571 |
self.ParentWindow.RefreshEditMenu() |
27 | 572 |
|
145 | 573 |
# Refresh the current scaling |
574 |
def RefreshScaling(self, refresh=True): |
|
249 | 575 |
properties = self.Controler.GetProjectProperties(self.Debug) |
145 | 576 |
scaling = properties["scaling"][self.CurrentLanguage] |
577 |
if scaling != (0, 0): |
|
578 |
self.Scaling = scaling |
|
579 |
if self.DrawGrid: |
|
323 | 580 |
width = max(2, int(scaling[0] * self.ViewScale[0])) |
581 |
height = max(2, int(scaling[1] * self.ViewScale[1])) |
|
582 |
bitmap = wx.EmptyBitmap(width, height) |
|
145 | 583 |
dc = wx.MemoryDC(bitmap) |
584 |
dc.SetBackground(wx.Brush(self.GetBackgroundColour())) |
|
585 |
dc.Clear() |
|
586 |
dc.SetPen(wx.Pen(wx.Colour(180, 180, 180))) |
|
587 |
dc.DrawPoint(0, 0) |
|
588 |
self.GridBrush = wx.BrushFromBitmap(bitmap) |
|
589 |
else: |
|
590 |
self.GridBrush = wx.TRANSPARENT_BRUSH |
|
591 |
else: |
|
592 |
self.Scaling = None |
|
593 |
self.GridBrush = wx.TRANSPARENT_BRUSH |
|
213 | 594 |
page_size = properties["pageSize"] |
595 |
if page_size != (0, 0): |
|
596 |
self.PageSize = map(int, page_size) |
|
597 |
self.PagePen = wx.Pen(wx.Colour(180, 180, 180)) |
|
598 |
else: |
|
599 |
self.PageSize = None |
|
600 |
self.PagePen = wx.TRANSPARENT_PEN |
|
145 | 601 |
if refresh: |
155 | 602 |
self.Refresh(False) |
145 | 603 |
|
604 |
||
0 | 605 |
#------------------------------------------------------------------------------- |
606 |
# Refresh functions |
|
607 |
#------------------------------------------------------------------------------- |
|
608 |
||
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
609 |
def ResetBuffer(self): |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
610 |
pass |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
611 |
|
0 | 612 |
# Refresh Viewer elements |
613 |
def RefreshView(self): |
|
614 |
self.current_id = 0 |
|
615 |
# Start by reseting Viewer |
|
249 | 616 |
self.Flush() |
0 | 617 |
self.ResetView() |
249 | 618 |
instance = {} |
0 | 619 |
# List of ids of already loaded blocks |
620 |
ids = [] |
|
621 |
# Load Blocks until they are all loaded |
|
249 | 622 |
while instance is not None: |
623 |
instance = self.Controler.GetEditedElementInstanceInfos(self.TagName, exclude = ids, debug = self.Debug) |
|
624 |
if instance is not None: |
|
0 | 625 |
self.loadInstance(instance, ids) |
42 | 626 |
self.RefreshScrollBars() |
121 | 627 |
|
628 |
for wire in self.Wires: |
|
629 |
if not wire.IsConnectedCompatible(): |
|
222
8ce5c2635976
Adding support for underlying type incompatible wire loaded instead of removing them
lbessard
parents:
218
diff
changeset
|
630 |
wire.MarkAsInvalid() |
249 | 631 |
if self.Debug: |
632 |
block = wire.EndConnected.GetParentBlock() |
|
633 |
if isinstance(block, LD_PowerRail): |
|
634 |
wire.SetValue(True) |
|
635 |
if isinstance(block, FBD_Block): |
|
636 |
blockname = block.GetName() |
|
637 |
connectorname = wire.EndConnected.GetName() |
|
638 |
if blockname != "": |
|
639 |
iec_path = "%s.%s.%s"%(self.InstancePath, block.GetName(), connectorname) |
|
640 |
else: |
|
641 |
if connectorname == "": |
|
279
2ad276084038
Bug involving possible name conflict between return value and ouputs fixed
lbessard
parents:
277
diff
changeset
|
642 |
iec_path = "%s.%s%d"%(self.InstancePath, block.GetType(), block.GetId()) |
2ad276084038
Bug involving possible name conflict between return value and ouputs fixed
lbessard
parents:
277
diff
changeset
|
643 |
else: |
2ad276084038
Bug involving possible name conflict between return value and ouputs fixed
lbessard
parents:
277
diff
changeset
|
644 |
iec_path = "%s.%s%d_%s"%(self.InstancePath, block.GetType(), block.GetId(), connectorname) |
253 | 645 |
if self.Controler.SubscribeDebugIECVariable(iec_path.upper(), wire) is not None: |
646 |
self.Subscribed[wire] = iec_path.upper() |
|
647 |
else: |
|
648 |
wire.SetValue("undefined") |
|
649 |
elif isinstance(block, FBD_Variable): |
|
650 |
iec_path = "%s.%s"%(self.InstancePath, block.GetName()) |
|
651 |
if self.Controler.SubscribeDebugIECVariable(iec_path.upper(), wire) is not None: |
|
652 |
self.Subscribed[wire] = iec_path.upper() |
|
653 |
else: |
|
654 |
wire.SetValue("undefined") |
|
655 |
elif isinstance(block, FBD_Connector): |
|
656 |
wire.SetValue("undefined") |
|
249 | 657 |
|
658 |
if self.Debug: |
|
659 |
for block in self.Blocks.keys(): |
|
253 | 660 |
block.SpreadCurrent() |
249 | 661 |
if isinstance(block, LD_Contact): |
662 |
iec_path = "%s.%s"%(self.InstancePath, block.GetName()) |
|
253 | 663 |
if self.Controler.SubscribeDebugIECVariable(iec_path.upper(), block) is not None: |
664 |
self.Subscribed[block] = iec_path.upper() |
|
665 |
elif isinstance(block, SFC_Step): |
|
666 |
iec_path = "%s.%s.X"%(self.InstancePath, block.GetName()) |
|
667 |
if self.Controler.SubscribeDebugIECVariable(iec_path.upper(), block) is not None: |
|
668 |
self.Subscribed[block] = iec_path.upper() |
|
669 |
elif isinstance(block, SFC_Transition): |
|
670 |
connectors = block.GetConnectors() |
|
671 |
previous_steps = self.GetPreviousSteps(connectors["input"]) |
|
672 |
next_steps = self.GetNextSteps(connectors["output"]) |
|
673 |
iec_path = "%s.%s->%s"%(self.InstancePath, ",".join(previous_steps), ",".join(next_steps)) |
|
674 |
if self.Controler.SubscribeDebugIECVariable(iec_path.upper(), block) is not None: |
|
675 |
self.Subscribed[block] = iec_path.upper() |
|
676 |
||
249 | 677 |
self.RefreshVisibleElements() |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
678 |
self.ShowErrors() |
155 | 679 |
self.Refresh(False) |
0 | 680 |
|
253 | 681 |
def GetPreviousSteps(self, connector): |
682 |
steps = [] |
|
683 |
for wire, handle in connector.GetWires(): |
|
684 |
previous = wire.GetOtherConnected(connector).GetParentBlock() |
|
685 |
if isinstance(previous, SFC_Step): |
|
686 |
steps.append(previous.GetName()) |
|
687 |
elif isinstance(previous, SFC_Divergence) and previous.GetType() in [SIMULTANEOUS_CONVERGENCE, SELECTION_DIVERGENCE]: |
|
688 |
connectors = previous.GetConnectors() |
|
689 |
for input in connectors["inputs"]: |
|
690 |
steps.extend(self.GetPreviousSteps(input)) |
|
691 |
return steps |
|
692 |
||
693 |
def GetNextSteps(self, connector): |
|
694 |
steps = [] |
|
695 |
for wire, handle in connector.GetWires(): |
|
696 |
next = wire.GetOtherConnected(connector).GetParentBlock() |
|
697 |
if isinstance(next, SFC_Step): |
|
698 |
steps.append(next.GetName()) |
|
699 |
elif isinstance(next, SFC_Jump): |
|
700 |
steps.append(next.GetTarget()) |
|
701 |
elif isinstance(next, SFC_Divergence) and next.GetType() in [SIMULTANEOUS_DIVERGENCE, SELECTION_CONVERGENCE]: |
|
702 |
connectors = next.GetConnectors() |
|
703 |
for output in connectors["outputs"]: |
|
704 |
steps.extend(self.GetNextSteps(output)) |
|
705 |
return steps |
|
706 |
||
213 | 707 |
def GetMaxSize(self): |
27 | 708 |
maxx = maxy = 0 |
42 | 709 |
for element in self.GetElements(): |
144 | 710 |
bbox = element.GetBoundingBox() |
711 |
maxx = max(maxx, bbox.x + bbox.width) |
|
712 |
maxy = max(maxy, bbox.y + bbox.height) |
|
213 | 713 |
return maxx, maxy |
714 |
||
319 | 715 |
def RefreshScrollBars(self, width_incr=0, height_incr=0): |
213 | 716 |
xstart, ystart = self.GetViewStart() |
717 |
window_size = self.GetClientSize() |
|
718 |
maxx, maxy = self.GetMaxSize() |
|
323 | 719 |
maxx = max(maxx + WINDOW_BORDER, (xstart * SCROLLBAR_UNIT + window_size[0]) / self.ViewScale[0]) |
720 |
maxy = max(maxy + WINDOW_BORDER, (ystart * SCROLLBAR_UNIT + window_size[1]) / self.ViewScale[1]) |
|
27 | 721 |
if self.rubberBand.IsShown(): |
722 |
extent = self.rubberBand.GetCurrentExtent() |
|
723 |
maxx = max(maxx, extent.x + extent.width) |
|
724 |
maxy = max(maxy, extent.y + extent.height) |
|
323 | 725 |
maxx = int(maxx * self.ViewScale[0]) |
726 |
maxy = int(maxy * self.ViewScale[1]) |
|
27 | 727 |
self.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
319 | 728 |
round(maxx / SCROLLBAR_UNIT) + width_incr, round(maxy / SCROLLBAR_UNIT) + height_incr, |
213 | 729 |
xstart, ystart, True) |
95 | 730 |
|
0 | 731 |
# Load instance from given informations |
732 |
def loadInstance(self, instance, ids): |
|
733 |
ids.append(instance["id"]) |
|
734 |
self.current_id = max(self.current_id, instance["id"]) |
|
735 |
if instance["type"] == "input": |
|
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
736 |
variable = FBD_Variable(self, INPUT, instance["name"], instance["value_type"], instance["id"], instance["executionOrder"]) |
0 | 737 |
variable.SetPosition(instance["x"], instance["y"]) |
738 |
variable.SetSize(instance["width"], instance["height"]) |
|
42 | 739 |
self.AddBlock(variable) |
0 | 740 |
connectors = variable.GetConnectors() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
741 |
connectors["output"].SetPosition(wx.Point(*instance["connector"]["position"])) |
0 | 742 |
if instance["connector"]["negated"]: |
743 |
connectors["output"].SetNegated(True) |
|
744 |
if instance["connector"]["edge"]: |
|
745 |
connectors["output"].SetEdge(instance["connector"]["edge"]) |
|
746 |
elif instance["type"] == "output": |
|
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
747 |
variable = FBD_Variable(self, OUTPUT, instance["name"], instance["value_type"], instance["id"], instance["executionOrder"]) |
0 | 748 |
variable.SetPosition(instance["x"], instance["y"]) |
749 |
variable.SetSize(instance["width"], instance["height"]) |
|
42 | 750 |
self.AddBlock(variable) |
0 | 751 |
connectors = variable.GetConnectors() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
752 |
connectors["input"].SetPosition(wx.Point(*instance["connector"]["position"])) |
0 | 753 |
if instance["connector"]["negated"]: |
754 |
connectors["input"].SetNegated(True) |
|
755 |
if instance["connector"]["edge"]: |
|
756 |
connectors["input"].SetEdge(instance["connector"]["edge"]) |
|
757 |
self.CreateWires(connectors["input"], instance["connector"]["links"], ids) |
|
758 |
elif instance["type"] == "inout": |
|
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
759 |
variable = FBD_Variable(self, INOUT, instance["name"], instance["value_type"], instance["id"], instance["executionOrder"]) |
0 | 760 |
variable.SetPosition(instance["x"], instance["y"]) |
761 |
variable.SetSize(instance["width"], instance["height"]) |
|
42 | 762 |
self.AddBlock(variable) |
0 | 763 |
connectors = variable.GetConnectors() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
764 |
connectors["output"].SetPosition(wx.Point(*instance["connectors"]["output"]["position"])) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
765 |
connectors["input"].SetPosition(wx.Point(*instance["connectors"]["input"]["position"])) |
0 | 766 |
if instance["connectors"]["output"]["negated"]: |
767 |
connectors["output"].SetNegated(True) |
|
768 |
if instance["connectors"]["output"]["edge"]: |
|
769 |
connectors["output"].SetEdge(instance["connectors"]["output"]["edge"]) |
|
770 |
if instance["connectors"]["input"]["negated"]: |
|
771 |
connectors["input"].SetNegated(True) |
|
772 |
if instance["connectors"]["input"]["edge"]: |
|
773 |
connectors["input"].SetEdge(instance["connectors"]["input"]["edge"]) |
|
774 |
self.CreateWires(connectors["input"], instance["connectors"]["input"]["links"], ids) |
|
775 |
elif instance["type"] == "continuation": |
|
776 |
connection = FBD_Connector(self, CONTINUATION, instance["name"], instance["id"]) |
|
777 |
connection.SetPosition(instance["x"], instance["y"]) |
|
778 |
connection.SetSize(instance["width"], instance["height"]) |
|
42 | 779 |
self.AddBlock(connection) |
0 | 780 |
connector = connection.GetConnector() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
781 |
connector.SetPosition(wx.Point(*instance["connector"]["position"])) |
0 | 782 |
elif instance["type"] == "connection": |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
783 |
connection = FBD_Connector(self, CONNECTOR, instance["name"], instance["id"]) |
0 | 784 |
connection.SetPosition(instance["x"], instance["y"]) |
785 |
connection.SetSize(instance["width"], instance["height"]) |
|
42 | 786 |
self.AddBlock(connection) |
0 | 787 |
connector = connection.GetConnector() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
788 |
connector.SetPosition(wx.Point(*instance["connector"]["position"])) |
0 | 789 |
self.CreateWires(connector, instance["connector"]["links"], ids) |
790 |
elif instance["type"] == "comment": |
|
791 |
comment = Comment(self, instance["content"], instance["id"]) |
|
792 |
comment.SetPosition(instance["x"], instance["y"]) |
|
793 |
comment.SetSize(instance["width"], instance["height"]) |
|
42 | 794 |
self.AddComment(comment) |
0 | 795 |
elif instance["type"] == "leftPowerRail": |
796 |
leftpowerrail = LD_PowerRail(self, LEFTRAIL, instance["id"], [True for i in range(len(instance["connectors"]))]) |
|
797 |
leftpowerrail.SetPosition(instance["x"], instance["y"]) |
|
80 | 798 |
leftpowerrail.SetSize(instance["width"], instance["height"]) |
42 | 799 |
self.AddBlock(leftpowerrail) |
0 | 800 |
connectors = leftpowerrail.GetConnectors() |
801 |
for i, connector in enumerate(instance["connectors"]): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
802 |
connectors[i].SetPosition(wx.Point(*connector["position"])) |
0 | 803 |
elif instance["type"] == "rightPowerRail": |
804 |
rightpowerrail = LD_PowerRail(self, RIGHTRAIL, instance["id"], [True for i in range(len(instance["connectors"]))]) |
|
805 |
rightpowerrail.SetPosition(instance["x"], instance["y"]) |
|
80 | 806 |
rightpowerrail.SetSize(instance["width"], instance["height"]) |
42 | 807 |
self.AddBlock(rightpowerrail) |
0 | 808 |
connectors = rightpowerrail.GetConnectors() |
809 |
for i, connector in enumerate(instance["connectors"]): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
810 |
connectors[i].SetPosition(wx.Point(*connector["position"])) |
0 | 811 |
self.CreateWires(connectors[i], connector["links"], ids) |
812 |
elif instance["type"] == "contact": |
|
813 |
if instance["negated"]: |
|
814 |
negated = instance["negated"] |
|
815 |
else: |
|
816 |
negated = False |
|
817 |
if instance["edge"]: |
|
818 |
edge = instance["edge"] |
|
819 |
else: |
|
820 |
edge = "none" |
|
821 |
if negated and edge == "none": |
|
822 |
contact_type = CONTACT_REVERSE |
|
823 |
elif not negated and edge == "rising": |
|
824 |
contact_type = CONTACT_RISING |
|
825 |
elif not negated and edge == "falling": |
|
826 |
contact_type = CONTACT_FALLING |
|
827 |
else: |
|
828 |
contact_type = CONTACT_NORMAL |
|
829 |
contact = LD_Contact(self, contact_type, instance["name"], instance["id"]) |
|
830 |
contact.SetPosition(instance["x"], instance["y"]) |
|
145 | 831 |
contact.SetSize(instance["width"], instance["height"]) |
42 | 832 |
self.AddBlock(contact) |
0 | 833 |
connectors = contact.GetConnectors() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
834 |
connectors["input"].SetPosition(wx.Point(*instance["connectors"]["input"]["position"])) |
0 | 835 |
self.CreateWires(connectors["input"], instance["connectors"]["input"]["links"], ids) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
836 |
connectors["output"].SetPosition(wx.Point(*instance["connectors"]["output"]["position"])) |
0 | 837 |
elif instance["type"] == "coil": |
838 |
if instance["negated"]: |
|
839 |
negated = instance["negated"] |
|
840 |
else: |
|
841 |
negated = False |
|
842 |
if instance["storage"]: |
|
843 |
storage = instance["storage"] |
|
844 |
else: |
|
845 |
storage = "none" |
|
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
846 |
if instance["edge"]: |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
847 |
edge = instance["edge"] |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
848 |
else: |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
849 |
edge = "none" |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
850 |
if negated and storage == "none" and edge == "none": |
0 | 851 |
coil_type = COIL_REVERSE |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
852 |
elif not negated and edge == "none" and storage == "set": |
0 | 853 |
coil_type = COIL_SET |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
854 |
elif not negated and edge == "none" and storage == "reset": |
0 | 855 |
coil_type = COIL_RESET |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
856 |
elif not negated and storage == "none" and edge == "rising": |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
857 |
coil_type = COIL_RISING |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
858 |
elif not negated and storage == "none" and edge == "falling": |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
859 |
coil_type = COIL_FALLING |
0 | 860 |
else: |
861 |
coil_type = COIL_NORMAL |
|
862 |
coil = LD_Coil(self, coil_type, instance["name"], instance["id"]) |
|
863 |
coil.SetPosition(instance["x"], instance["y"]) |
|
145 | 864 |
coil.SetSize(instance["width"], instance["height"]) |
42 | 865 |
self.AddBlock(coil) |
0 | 866 |
connectors = coil.GetConnectors() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
867 |
connectors["input"].SetPosition(wx.Point(*instance["connectors"]["input"]["position"])) |
0 | 868 |
self.CreateWires(connectors["input"], instance["connectors"]["input"]["links"], ids) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
869 |
connectors["output"].SetPosition(wx.Point(*instance["connectors"]["output"]["position"])) |
0 | 870 |
elif instance["type"] == "step": |
871 |
if instance["initial"]: |
|
872 |
initial = instance["initial"] |
|
873 |
else: |
|
874 |
initial = False |
|
875 |
step = SFC_Step(self, instance["name"], initial, instance["id"]) |
|
876 |
step.SetPosition(instance["x"], instance["y"]) |
|
877 |
step.SetSize(instance["width"], instance["height"]) |
|
42 | 878 |
self.AddBlock(step) |
0 | 879 |
if "output" in instance["connectors"]: |
880 |
step.AddOutput() |
|
881 |
if "action" in instance["connectors"]: |
|
882 |
step.AddAction() |
|
883 |
connectors = step.GetConnectors() |
|
884 |
if connectors["input"]: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
885 |
connectors["input"].SetPosition(wx.Point(*instance["connectors"]["input"]["position"])) |
0 | 886 |
self.CreateWires(connectors["input"], instance["connectors"]["input"]["links"], ids) |
887 |
if connectors["output"]: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
888 |
connectors["output"].SetPosition(wx.Point(*instance["connectors"]["output"]["position"])) |
0 | 889 |
if connectors["action"]: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
890 |
connectors["action"].SetPosition(wx.Point(*instance["connectors"]["action"]["position"])) |
0 | 891 |
elif instance["type"] == "transition": |
80 | 892 |
transition = SFC_Transition(self, instance["condition_type"], instance["condition"], instance["priority"], instance["id"]) |
0 | 893 |
transition.SetPosition(instance["x"], instance["y"]) |
145 | 894 |
transition.SetSize(instance["width"], instance["height"]) |
42 | 895 |
self.AddBlock(transition) |
0 | 896 |
connectors = transition.GetConnectors() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
897 |
connectors["input"].SetPosition(wx.Point(*instance["connectors"]["input"]["position"])) |
0 | 898 |
self.CreateWires(connectors["input"], instance["connectors"]["input"]["links"], ids) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
899 |
connectors["output"].SetPosition(wx.Point(*instance["connectors"]["output"]["position"])) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
900 |
if instance["condition_type"] == "connection": |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
901 |
self.CreateWires(connectors["connection"], instance["connectors"]["connection"]["links"], ids) |
0 | 902 |
elif instance["type"] in ["selectionDivergence", "selectionConvergence", "simultaneousDivergence", "simultaneousConvergence"]: |
903 |
if instance["type"] == "selectionDivergence": |
|
904 |
divergence = SFC_Divergence(self, SELECTION_DIVERGENCE, |
|
905 |
len(instance["connectors"]["outputs"]), instance["id"]) |
|
906 |
elif instance["type"] == "selectionConvergence": |
|
907 |
divergence = SFC_Divergence(self, SELECTION_CONVERGENCE, |
|
908 |
len(instance["connectors"]["inputs"]), instance["id"]) |
|
909 |
elif instance["type"] == "simultaneousDivergence": |
|
910 |
divergence = SFC_Divergence(self, SIMULTANEOUS_DIVERGENCE, |
|
911 |
len(instance["connectors"]["outputs"]), instance["id"]) |
|
912 |
else: |
|
913 |
divergence = SFC_Divergence(self, SIMULTANEOUS_CONVERGENCE, |
|
914 |
len(instance["connectors"]["inputs"]), instance["id"]) |
|
915 |
divergence.SetPosition(instance["x"], instance["y"]) |
|
916 |
divergence.SetSize(instance["width"], instance["height"]) |
|
42 | 917 |
self.AddBlock(divergence) |
0 | 918 |
connectors = divergence.GetConnectors() |
919 |
for i, input_connector in enumerate(instance["connectors"]["inputs"]): |
|
920 |
connector = connectors["inputs"][i] |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
921 |
connector.SetPosition(wx.Point(*input_connector["position"])) |
0 | 922 |
self.CreateWires(connector, input_connector["links"], ids) |
923 |
for i, output_connector in enumerate(instance["connectors"]["outputs"]): |
|
924 |
connector = connectors["outputs"][i] |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
925 |
connector.SetPosition(wx.Point(*output_connector["position"])) |
0 | 926 |
elif instance["type"] == "jump": |
927 |
jump = SFC_Jump(self, instance["target"], instance["id"]) |
|
928 |
jump.SetPosition(instance["x"], instance["y"]) |
|
145 | 929 |
jump.SetSize(instance["width"], instance["height"]) |
42 | 930 |
self.AddBlock(jump) |
0 | 931 |
connector = jump.GetConnector() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
932 |
connector.SetPosition(wx.Point(*instance["connector"]["position"])) |
0 | 933 |
self.CreateWires(connector, instance["connector"]["links"], ids) |
934 |
elif instance["type"] == "actionBlock": |
|
935 |
actionBlock = SFC_ActionBlock(self, instance["actions"], instance["id"]) |
|
936 |
actionBlock.SetPosition(instance["x"], instance["y"]) |
|
937 |
actionBlock.SetSize(instance["width"], instance["height"]) |
|
42 | 938 |
self.AddBlock(actionBlock) |
0 | 939 |
connector = actionBlock.GetConnector() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
940 |
connector.SetPosition(wx.Point(*instance["connector"]["position"])) |
0 | 941 |
self.CreateWires(connector, instance["connector"]["links"], ids) |
942 |
else: |
|
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
943 |
connectors = {"inputs" : [], "outputs" : []} |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
944 |
executionControl = False |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
945 |
for input in instance["connectors"]["inputs"]: |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
946 |
if input["negated"]: |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
947 |
connectors["inputs"].append((input["name"], None, "negated")) |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
948 |
elif input["edge"]: |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
949 |
connectors["inputs"].append((input["name"], None, input["edge"])) |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
950 |
else: |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
951 |
connectors["inputs"].append((input["name"], None, "none")) |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
952 |
for output in instance["connectors"]["outputs"]: |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
953 |
if output["negated"]: |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
954 |
connectors["outputs"].append((output["name"], None, "negated")) |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
955 |
elif output["edge"]: |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
956 |
connectors["outputs"].append((output["name"], None, output["edge"])) |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
957 |
else: |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
958 |
connectors["outputs"].append((output["name"], None, "none")) |
290
56c4fe6b7012
Bug when searching for EN/ENO on block without interface fixed
greg
parents:
283
diff
changeset
|
959 |
if len(connectors["inputs"]) > 0 and connectors["inputs"][0][0] == "EN": |
56c4fe6b7012
Bug when searching for EN/ENO on block without interface fixed
greg
parents:
283
diff
changeset
|
960 |
connectors["inputs"].pop(0) |
56c4fe6b7012
Bug when searching for EN/ENO on block without interface fixed
greg
parents:
283
diff
changeset
|
961 |
executionControl = True |
56c4fe6b7012
Bug when searching for EN/ENO on block without interface fixed
greg
parents:
283
diff
changeset
|
962 |
if len(connectors["outputs"]) > 0 and connectors["outputs"][0][0] == "ENO": |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
963 |
connectors["outputs"].pop(0) |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
964 |
executionControl = True |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
965 |
if instance["name"] is None: |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
966 |
instance["name"] = "" |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
967 |
block = FBD_Block(self, instance["type"], instance["name"], |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
968 |
instance["id"], len(connectors["inputs"]), |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
969 |
connectors=connectors, executionControl=executionControl, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
970 |
executionOrder=instance["executionOrder"]) |
0 | 971 |
block.SetPosition(instance["x"], instance["y"]) |
972 |
block.SetSize(instance["width"], instance["height"]) |
|
42 | 973 |
self.AddBlock(block) |
0 | 974 |
connectors = block.GetConnectors() |
975 |
for i, input_connector in enumerate(instance["connectors"]["inputs"]): |
|
195
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
976 |
if i < len(connectors["inputs"]): |
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
977 |
connector = connectors["inputs"][i] |
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
978 |
connector.SetPosition(wx.Point(*input_connector["position"])) |
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
979 |
if input_connector["negated"]: |
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
980 |
connector.SetNegated(True) |
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
981 |
if input_connector["edge"] != "none": |
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
982 |
connector.SetEdge(input_connector["edge"]) |
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
983 |
self.CreateWires(connector, input_connector["links"], ids) |
0 | 984 |
for i, output_connector in enumerate(instance["connectors"]["outputs"]): |
195
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
985 |
if i < len(connectors["outputs"]): |
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
986 |
connector = connectors["outputs"][i] |
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
987 |
if output_connector["negated"]: |
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
988 |
connector.SetNegated(True) |
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
989 |
if output_connector["edge"] != "none": |
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
990 |
connector.SetEdge(output_connector["edge"]) |
d9084f6eecfd
Adding Function Block name test in Viewer Drop Target
lbessard
parents:
178
diff
changeset
|
991 |
connector.SetPosition(wx.Point(*output_connector["position"])) |
0 | 992 |
|
993 |
def CreateWires(self, start_connector, links, ids): |
|
994 |
for link in links: |
|
995 |
refLocalId = link["refLocalId"] |
|
249 | 996 |
if refLocalId is not None: |
0 | 997 |
if refLocalId not in ids: |
249 | 998 |
new_instance = self.Controler.GetEditedElementInstanceInfos(self.TagName, refLocalId, debug = self.Debug) |
999 |
if new_instance is not None: |
|
0 | 1000 |
self.loadInstance(new_instance, ids) |
1001 |
connected = self.FindElementById(refLocalId) |
|
249 | 1002 |
if connected is not None: |
0 | 1003 |
points = link["points"] |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1004 |
end_connector = connected.GetConnector(wx.Point(points[-1][0], points[-1][1]), link["formalParameter"]) |
249 | 1005 |
if end_connector is not None: |
0 | 1006 |
wire = Wire(self) |
1007 |
wire.SetPoints(points) |
|
1008 |
start_connector.Connect((wire, 0), False) |
|
1009 |
end_connector.Connect((wire, -1), False) |
|
1010 |
wire.ConnectStartPoint(None, start_connector) |
|
1011 |
wire.ConnectEndPoint(None, end_connector) |
|
42 | 1012 |
self.AddWire(wire) |
0 | 1013 |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1014 |
def IsOfType(self, type, reference): |
249 | 1015 |
return self.Controler.IsOfType(type, reference, self.Debug) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1016 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1017 |
def IsEndType(self, type): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1018 |
return self.Controler.IsEndType(type) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1019 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1020 |
def GetBlockType(self, type, inputs = None): |
249 | 1021 |
return self.Controler.GetBlockType(type, inputs, self.Debug) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1022 |
|
0 | 1023 |
#------------------------------------------------------------------------------- |
1024 |
# Search Element functions |
|
1025 |
#------------------------------------------------------------------------------- |
|
1026 |
||
1027 |
def FindBlock(self, pos): |
|
1028 |
for block in self.Blocks: |
|
1029 |
if block.HitTest(pos) or block.TestHandle(pos) != (0, 0): |
|
1030 |
return block |
|
1031 |
return None |
|
1032 |
||
1033 |
def FindWire(self, pos): |
|
1034 |
for wire in self.Wires: |
|
1035 |
if wire.HitTest(pos) or wire.TestHandle(pos) != (0, 0): |
|
1036 |
return wire |
|
1037 |
return None |
|
1038 |
||
1039 |
def FindElement(self, pos, exclude_group = False): |
|
1040 |
if self.SelectedElement and not (exclude_group and isinstance(self.SelectedElement, Graphic_Group)): |
|
1041 |
if self.SelectedElement.HitTest(pos) or self.SelectedElement.TestHandle(pos) != (0, 0): |
|
1042 |
return self.SelectedElement |
|
42 | 1043 |
for element in self.GetElements(): |
0 | 1044 |
if element.HitTest(pos) or element.TestHandle(pos) != (0, 0): |
1045 |
return element |
|
1046 |
return None |
|
1047 |
||
249 | 1048 |
def FindBlockConnector(self, pos, direction = None, exclude = None): |
0 | 1049 |
for block in self.Blocks: |
243
c5da8b706cde
Adding support for allowing connections only between an input and an output connector
lbessard
parents:
239
diff
changeset
|
1050 |
result = block.TestConnector(pos, direction, exclude) |
0 | 1051 |
if result: |
1052 |
return result |
|
1053 |
return None |
|
1054 |
||
1055 |
def FindElementById(self, id): |
|
42 | 1056 |
for element in self.Blocks: |
1057 |
if element.GetId() == id: |
|
1058 |
return element |
|
1059 |
for element in self.Comments: |
|
0 | 1060 |
if element.GetId() == id: |
1061 |
return element |
|
1062 |
return None |
|
1063 |
||
1064 |
def SearchElements(self, bbox): |
|
1065 |
elements = [] |
|
42 | 1066 |
for element in self.GetElements(): |
1067 |
if element.IsInSelection(bbox): |
|
0 | 1068 |
elements.append(element) |
1069 |
return elements |
|
1070 |
||
1071 |
#------------------------------------------------------------------------------- |
|
1072 |
# Popup menu functions |
|
1073 |
#------------------------------------------------------------------------------- |
|
1074 |
||
1075 |
def PopupBlockMenu(self, connector = None): |
|
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
1076 |
if connector is not None and connector.IsCompatible("BOOL"): |
249 | 1077 |
type = self.Controler.GetEditedElementType(self.TagName, self.Debug) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1078 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS0, True) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1079 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS1, True) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1080 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS2, type != "function") |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1081 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS3, type != "function") |
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
1082 |
else: |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1083 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS0, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1084 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS1, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1085 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS2, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1086 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS3, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1087 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS5, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1088 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS6, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1089 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS8, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1090 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS9, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1091 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS14, False) |
249 | 1092 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS16, self.SelectedElement.GetType() in self.Controler.GetProjectPouNames(self.Debug)) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1093 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS17, True) |
249 | 1094 |
if connector is not None: |
0 | 1095 |
if connector.IsNegated(): |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1096 |
self.ContextualMenu.Check(ID_VIEWERCONTEXTUALMENUITEMS1, True) |
0 | 1097 |
elif connector.GetEdge() == "rising": |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1098 |
self.ContextualMenu.Check(ID_VIEWERCONTEXTUALMENUITEMS2, True) |
0 | 1099 |
elif connector.GetEdge() == "falling": |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1100 |
self.ContextualMenu.Check(ID_VIEWERCONTEXTUALMENUITEMS3, True) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1101 |
else: |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1102 |
self.ContextualMenu.Check(ID_VIEWERCONTEXTUALMENUITEMS0, True) |
0 | 1103 |
self.PopupMenu(self.ContextualMenu) |
1104 |
||
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1105 |
def PopupWireMenu(self, delete=True): |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1106 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS0, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1107 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS1, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1108 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS2, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1109 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS3, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1110 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS5, True) |
235
7b58a3b5b6ec
Change in layout from AuiMDIParentFrame to AuiNotebook
lbessard
parents:
231
diff
changeset
|
1111 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS6, delete) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1112 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS8, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1113 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS9, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1114 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS14, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1115 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS16, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1116 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS17, True) |
0 | 1117 |
self.PopupMenu(self.ContextualMenu) |
1118 |
||
1119 |
def PopupDivergenceMenu(self, connector): |
|
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1120 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS0, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1121 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS1, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1122 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS2, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1123 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS3, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1124 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS5, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1125 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS6, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1126 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS8, True) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1127 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS9, connector) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1128 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS14, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1129 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS16, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1130 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS17, True) |
0 | 1131 |
self.PopupMenu(self.ContextualMenu) |
1132 |
||
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1133 |
def PopupGroupMenu(self): |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1134 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS0, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1135 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS1, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1136 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS2, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1137 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS3, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1138 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS5, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1139 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS6, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1140 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS8, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1141 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS9, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1142 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS14, True) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1143 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS16, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1144 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS17, True) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1145 |
self.PopupMenu(self.ContextualMenu) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1146 |
|
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1147 |
def PopupDefaultMenu(self, block = True): |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1148 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS0, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1149 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS1, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1150 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS2, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1151 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS3, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1152 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS5, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1153 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS6, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1154 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS8, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1155 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS9, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1156 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS14, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1157 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS16, False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1158 |
self.ContextualMenu.Enable(ID_VIEWERCONTEXTUALMENUITEMS17, block) |
0 | 1159 |
self.PopupMenu(self.ContextualMenu) |
1160 |
||
1161 |
#------------------------------------------------------------------------------- |
|
1162 |
# Menu items functions |
|
1163 |
#------------------------------------------------------------------------------- |
|
1164 |
||
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1165 |
def OnAlignLeftMenu(self, event): |
249 | 1166 |
if self.SelectedElement is not None and isinstance(self.SelectedElement, Graphic_Group): |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1167 |
self.SelectedElement.AlignElements(ALIGN_LEFT, None) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1168 |
self.RefreshBuffer() |
155 | 1169 |
self.Refresh(False) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1170 |
event.Skip() |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1171 |
|
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1172 |
def OnAlignCenterMenu(self, event): |
249 | 1173 |
if self.SelectedElement is not None and isinstance(self.SelectedElement, Graphic_Group): |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1174 |
self.SelectedElement.AlignElements(ALIGN_CENTER, None) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1175 |
self.RefreshBuffer() |
155 | 1176 |
self.Refresh(False) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1177 |
event.Skip() |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1178 |
|
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1179 |
def OnAlignRightMenu(self, event): |
249 | 1180 |
if self.SelectedElement is not None and isinstance(self.SelectedElement, Graphic_Group): |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1181 |
self.SelectedElement.AlignElements(ALIGN_RIGHT, None) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1182 |
self.RefreshBuffer() |
155 | 1183 |
self.Refresh(False) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1184 |
event.Skip() |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1185 |
|
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1186 |
def OnAlignTopMenu(self, event): |
249 | 1187 |
if self.SelectedElement is not None and isinstance(self.SelectedElement, Graphic_Group): |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1188 |
self.SelectedElement.AlignElements(None, ALIGN_TOP) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1189 |
self.RefreshBuffer() |
155 | 1190 |
self.Refresh(False) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1191 |
event.Skip() |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1192 |
|
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1193 |
def OnAlignMiddleMenu(self, event): |
249 | 1194 |
if self.SelectedElement is not None and isinstance(self.SelectedElement, Graphic_Group): |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1195 |
self.SelectedElement.AlignElements(None, ALIGN_MIDDLE) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1196 |
self.RefreshBuffer() |
155 | 1197 |
self.Refresh(False) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1198 |
event.Skip() |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1199 |
|
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1200 |
def OnAlignBottomMenu(self, event): |
249 | 1201 |
if self.SelectedElement is not None and isinstance(self.SelectedElement, Graphic_Group): |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1202 |
self.SelectedElement.AlignElements(None, ALIGN_BOTTOM) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1203 |
self.RefreshBuffer() |
155 | 1204 |
self.Refresh(False) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1205 |
event.Skip() |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1206 |
|
0 | 1207 |
def OnNoModifierMenu(self, event): |
249 | 1208 |
if self.SelectedElement is not None and self.IsBlock(self.SelectedElement): |
0 | 1209 |
self.SelectedElement.SetConnectorNegated(False) |
206 | 1210 |
self.SelectedElement.Refresh() |
80 | 1211 |
self.RefreshBuffer() |
0 | 1212 |
event.Skip() |
1213 |
||
1214 |
def OnNegatedMenu(self, event): |
|
249 | 1215 |
if self.SelectedElement is not None and self.IsBlock(self.SelectedElement): |
0 | 1216 |
self.SelectedElement.SetConnectorNegated(True) |
206 | 1217 |
self.SelectedElement.Refresh() |
80 | 1218 |
self.RefreshBuffer() |
0 | 1219 |
event.Skip() |
1220 |
||
1221 |
def OnRisingEdgeMenu(self, event): |
|
249 | 1222 |
if self.SelectedElement is not None and self.IsBlock(self.SelectedElement): |
0 | 1223 |
self.SelectedElement.SetConnectorEdge("rising") |
206 | 1224 |
self.SelectedElement.Refresh() |
80 | 1225 |
self.RefreshBuffer() |
0 | 1226 |
event.Skip() |
1227 |
||
1228 |
def OnFallingEdgeMenu(self, event): |
|
249 | 1229 |
if self.SelectedElement is not None and self.IsBlock(self.SelectedElement): |
0 | 1230 |
self.SelectedElement.SetConnectorEdge("falling") |
206 | 1231 |
self.SelectedElement.Refresh() |
80 | 1232 |
self.RefreshBuffer() |
0 | 1233 |
event.Skip() |
1234 |
||
1235 |
def OnAddSegmentMenu(self, event): |
|
249 | 1236 |
if self.SelectedElement is not None and self.IsWire(self.SelectedElement): |
0 | 1237 |
self.SelectedElement.AddSegment() |
206 | 1238 |
self.SelectedElement.Refresh() |
0 | 1239 |
event.Skip() |
1240 |
||
1241 |
def OnDeleteSegmentMenu(self, event): |
|
249 | 1242 |
if self.SelectedElement is not None and self.IsWire(self.SelectedElement): |
0 | 1243 |
self.SelectedElement.DeleteSegment() |
206 | 1244 |
self.SelectedElement.Refresh() |
0 | 1245 |
event.Skip() |
1246 |
||
1247 |
def OnAddBranchMenu(self, event): |
|
249 | 1248 |
if self.SelectedElement is not None and self.IsBlock(self.SelectedElement): |
0 | 1249 |
self.AddDivergenceBranch(self.SelectedElement) |
1250 |
event.Skip() |
|
1251 |
||
1252 |
def OnDeleteBranchMenu(self, event): |
|
249 | 1253 |
if self.SelectedElement is not None and self.IsBlock(self.SelectedElement): |
0 | 1254 |
self.RemoveDivergenceBranch(self.SelectedElement) |
1255 |
event.Skip() |
|
1256 |
||
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
1257 |
def OnEditBlockMenu(self, event): |
249 | 1258 |
if self.SelectedElement is not None: |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1259 |
self.ParentWindow.EditProjectElement(ITEM_POU, "P::%s"%self.SelectedElement.GetType()) |
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
1260 |
event.Skip() |
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
1261 |
|
0 | 1262 |
def OnDeleteMenu(self, event): |
249 | 1263 |
if self.SelectedElement is not None: |
0 | 1264 |
self.SelectedElement.Delete() |
1265 |
self.SelectedElement = None |
|
80 | 1266 |
self.RefreshBuffer() |
206 | 1267 |
self.Refresh(False) |
0 | 1268 |
event.Skip() |
1269 |
||
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1270 |
def OnClearExecutionOrderMenu(self, event): |
121 | 1271 |
self.Controler.ClearEditedElementExecutionOrder(self.TagName) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1272 |
self.RefreshBuffer() |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1273 |
self.RefreshView() |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1274 |
|
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1275 |
def OnResetExecutionOrderMenu(self, event): |
121 | 1276 |
self.Controler.ResetEditedElementExecutionOrder(self.TagName) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1277 |
self.RefreshBuffer() |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1278 |
self.RefreshView() |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1279 |
|
0 | 1280 |
#------------------------------------------------------------------------------- |
1281 |
# Mouse event functions |
|
1282 |
#------------------------------------------------------------------------------- |
|
1283 |
||
1284 |
def OnViewerLeftDown(self, event): |
|
27 | 1285 |
if self.Mode == MODE_SELECTION: |
1286 |
dc = self.GetLogicalDC() |
|
1287 |
pos = event.GetLogicalPosition(dc) |
|
327
7fd5233ce5ce
Adding support for contraining move to only one direction when control down
lbessard
parents:
323
diff
changeset
|
1288 |
if event.ShiftDown() and self.SelectedElement is not None: |
27 | 1289 |
element = self.FindElement(pos, True) |
249 | 1290 |
if element is not None: |
27 | 1291 |
if isinstance(self.SelectedElement, Graphic_Group): |
1292 |
self.SelectedElement.SetSelected(False) |
|
1293 |
self.SelectedElement.SelectElement(element) |
|
249 | 1294 |
elif self.SelectedElement is not None: |
27 | 1295 |
group = Graphic_Group(self) |
1296 |
group.SelectElement(self.SelectedElement) |
|
1297 |
group.SelectElement(element) |
|
1298 |
self.SelectedElement = group |
|
1299 |
elements = self.SelectedElement.GetElements() |
|
1300 |
if len(elements) == 0: |
|
1301 |
self.SelectedElement = element |
|
1302 |
elif len(elements) == 1: |
|
1303 |
self.SelectedElement = elements[0] |
|
1304 |
self.SelectedElement.SetSelected(True) |
|
1305 |
else: |
|
1306 |
element = self.FindElement(pos) |
|
249 | 1307 |
if not self.Debug and (element is None or element.TestHandle(pos) == (0, 0)): |
145 | 1308 |
connector = self.FindBlockConnector(pos) |
1309 |
else: |
|
1310 |
connector = None |
|
249 | 1311 |
if not self.Debug and self.DrawingWire: |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1312 |
self.DrawingWire = False |
174 | 1313 |
if self.SelectedElement is not None: |
243
c5da8b706cde
Adding support for allowing connections only between an input and an output connector
lbessard
parents:
239
diff
changeset
|
1314 |
if element is None or element.TestHandle(pos) == (0, 0): |
c5da8b706cde
Adding support for allowing connections only between an input and an output connector
lbessard
parents:
239
diff
changeset
|
1315 |
connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection()) |
249 | 1316 |
if connector is not None: |
174 | 1317 |
event.Dragging = lambda : True |
1318 |
self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling) |
|
1319 |
if self.SelectedElement.EndConnected is not None: |
|
1320 |
self.SelectedElement.ResetPoints() |
|
1321 |
self.SelectedElement.GeneratePoints() |
|
1322 |
self.SelectedElement.RefreshModel() |
|
1323 |
self.SelectedElement.SetSelected(True) |
|
1324 |
element = self.SelectedElement |
|
1325 |
self.RefreshBuffer() |
|
1326 |
else: |
|
1327 |
rect = self.SelectedElement.GetRedrawRect() |
|
1328 |
self.SelectedElement.Delete() |
|
1329 |
self.SelectedElement = None |
|
1330 |
element = None |
|
1331 |
self.RefreshRect(self.GetScrolledRect(rect), False) |
|
249 | 1332 |
elif not self.Debug and connector is not None: |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1333 |
self.DrawingWire = True |
216
93af9ac5aeaf
Not connecting wire on scaled graphics bug and forbidding copy on the fly of groups fixed
lbessard
parents:
213
diff
changeset
|
1334 |
scaled_pos = GetScaledEventPosition(event, self.GetLogicalDC(), self.Scaling) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1335 |
if (connector.GetDirection() == EAST): |
216
93af9ac5aeaf
Not connecting wire on scaled graphics bug and forbidding copy on the fly of groups fixed
lbessard
parents:
213
diff
changeset
|
1336 |
wire = Wire(self, [wx.Point(pos.x, pos.y), EAST], [wx.Point(scaled_pos.x, scaled_pos.y), WEST]) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1337 |
else: |
216
93af9ac5aeaf
Not connecting wire on scaled graphics bug and forbidding copy on the fly of groups fixed
lbessard
parents:
213
diff
changeset
|
1338 |
wire = Wire(self, [wx.Point(pos.x, pos.y), WEST], [wx.Point(scaled_pos.x, scaled_pos.y), EAST]) |
93af9ac5aeaf
Not connecting wire on scaled graphics bug and forbidding copy on the fly of groups fixed
lbessard
parents:
213
diff
changeset
|
1339 |
wire.oldPos = scaled_pos |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1340 |
wire.Handle = (HANDLE_POINT, 0) |
327
7fd5233ce5ce
Adding support for contraining move to only one direction when control down
lbessard
parents:
323
diff
changeset
|
1341 |
wire.ProcessDragging(0, 0, event, None) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1342 |
wire.Handle = (HANDLE_POINT, 1) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1343 |
self.AddWire(wire) |
249 | 1344 |
if self.SelectedElement is not None: |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1345 |
self.SelectedElement.SetSelected(False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1346 |
self.SelectedElement = wire |
259 | 1347 |
self.RefreshVisibleElements() |
144 | 1348 |
self.SelectedElement.Refresh() |
27 | 1349 |
else: |
249 | 1350 |
if self.SelectedElement is not None and self.SelectedElement != element: |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1351 |
self.SelectedElement.SetSelected(False) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1352 |
self.SelectedElement = None |
249 | 1353 |
if element is not None: |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1354 |
self.SelectedElement = element |
249 | 1355 |
if self.Debug: |
1356 |
Graphic_Element.OnLeftDown(self.SelectedElement, event, dc, self.Scaling) |
|
1357 |
else: |
|
1358 |
self.SelectedElement.OnLeftDown(event, dc, self.Scaling) |
|
144 | 1359 |
self.SelectedElement.Refresh() |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1360 |
else: |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1361 |
self.rubberBand.Reset() |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1362 |
self.rubberBand.OnLeftDown(event, dc, self.Scaling) |
27 | 1363 |
elif self.Mode in [MODE_BLOCK, MODE_VARIABLE, MODE_CONNECTION, MODE_COMMENT, |
1364 |
MODE_CONTACT, MODE_COIL, MODE_POWERRAIL, MODE_INITIALSTEP, |
|
1365 |
MODE_STEP, MODE_TRANSITION, MODE_DIVERGENCE, MODE_JUMP, MODE_ACTION]: |
|
1366 |
self.rubberBand.Reset() |
|
1367 |
self.rubberBand.OnLeftDown(event, self.GetLogicalDC(), self.Scaling) |
|
0 | 1368 |
event.Skip() |
1369 |
||
1370 |
def OnViewerLeftUp(self, event): |
|
27 | 1371 |
if self.rubberBand.IsShown(): |
1372 |
if self.Mode == MODE_SELECTION: |
|
1373 |
elements = self.SearchElements(self.rubberBand.GetCurrentExtent()) |
|
1374 |
self.rubberBand.OnLeftUp(event, self.GetLogicalDC(), self.Scaling) |
|
80 | 1375 |
if len(elements) == 1: |
1376 |
self.SelectedElement = elements[0] |
|
1377 |
self.SelectedElement.SetSelected(True) |
|
1378 |
elif len(elements) > 1: |
|
27 | 1379 |
self.SelectedElement = Graphic_Group(self) |
1380 |
self.SelectedElement.SetElements(elements) |
|
1381 |
self.SelectedElement.SetSelected(True) |
|
1382 |
else: |
|
1383 |
bbox = self.rubberBand.GetCurrentExtent() |
|
1384 |
self.rubberBand.OnLeftUp(event, self.GetLogicalDC(), self.Scaling) |
|
1385 |
if self.Mode == MODE_BLOCK: |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1386 |
wx.CallAfter(self.AddNewBlock, bbox) |
27 | 1387 |
elif self.Mode == MODE_VARIABLE: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1388 |
wx.CallAfter(self.AddNewVariable, bbox) |
27 | 1389 |
elif self.Mode == MODE_CONNECTION: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1390 |
wx.CallAfter(self.AddNewConnection, bbox) |
27 | 1391 |
elif self.Mode == MODE_COMMENT: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1392 |
wx.CallAfter(self.AddNewComment, bbox) |
27 | 1393 |
elif self.Mode == MODE_CONTACT: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1394 |
wx.CallAfter(self.AddNewContact, bbox) |
27 | 1395 |
elif self.Mode == MODE_COIL: |
67
3a1b0afdaf84
Adding support for automatically generate function blocks in interface when a block is added
lbessard
parents:
64
diff
changeset
|
1396 |
wx.CallAfter(self.AddNewCoil, bbox) |
27 | 1397 |
elif self.Mode == MODE_POWERRAIL: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1398 |
wx.CallAfter(self.AddNewPowerRail, bbox) |
27 | 1399 |
elif self.Mode == MODE_INITIALSTEP: |
71 | 1400 |
wx.CallAfter(self.AddNewStep, bbox, True) |
27 | 1401 |
elif self.Mode == MODE_STEP: |
71 | 1402 |
wx.CallAfter(self.AddNewStep, bbox, False) |
27 | 1403 |
elif self.Mode == MODE_TRANSITION: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1404 |
wx.CallAfter(self.AddNewTransition, bbox) |
27 | 1405 |
elif self.Mode == MODE_DIVERGENCE: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1406 |
wx.CallAfter(self.AddNewDivergence, bbox) |
27 | 1407 |
elif self.Mode == MODE_JUMP: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1408 |
wx.CallAfter(self.AddNewJump, bbox) |
27 | 1409 |
elif self.Mode == MODE_ACTION: |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1410 |
wx.CallAfter(self.AddNewActionBlock, bbox) |
249 | 1411 |
elif self.Mode == MODE_SELECTION and self.SelectedElement is not None: |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1412 |
dc = self.GetLogicalDC() |
249 | 1413 |
if not self.Debug and self.DrawingWire: |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1414 |
pos = event.GetLogicalPosition(dc) |
243
c5da8b706cde
Adding support for allowing connections only between an input and an output connector
lbessard
parents:
239
diff
changeset
|
1415 |
connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection()) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1416 |
if self.SelectedElement.EndConnected is not None: |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1417 |
self.DrawingWire = False |
145 | 1418 |
self.SelectedElement.StartConnected.HighlightParentBlock(False) |
1419 |
self.SelectedElement.EndConnected.HighlightParentBlock(False) |
|
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1420 |
self.SelectedElement.ResetPoints() |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1421 |
self.SelectedElement.OnMotion(event, dc, self.Scaling) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1422 |
self.SelectedElement.GeneratePoints() |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1423 |
self.SelectedElement.RefreshModel() |
145 | 1424 |
if self.HighlightedElement is not None: |
1425 |
self.HighlightedElement.SetHighlighted(False) |
|
1426 |
self.HighlightedElement = None |
|
1427 |
self.SelectedElement.SetHighlighted(True) |
|
1428 |
self.HighlightedElement = self.SelectedElement |
|
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1429 |
self.SelectedElement.SetSelected(True) |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1430 |
self.RefreshBuffer() |
144 | 1431 |
elif connector is None or self.SelectedElement.GetDragging(): |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1432 |
self.DrawingWire = False |
144 | 1433 |
rect = self.SelectedElement.GetRedrawRect() |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1434 |
self.SelectedElement.Delete() |
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1435 |
self.SelectedElement = None |
155 | 1436 |
self.RefreshRect(self.GetScrolledRect(rect), False) |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1437 |
else: |
249 | 1438 |
if self.Debug: |
1439 |
Graphic_Element.OnLeftUp(self.SelectedElement, event, dc, self.Scaling) |
|
1440 |
else: |
|
1441 |
self.SelectedElement.OnLeftUp(event, dc, self.Scaling) |
|
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1442 |
wx.CallAfter(self.SetCursor, wx.NullCursor) |
106
3fc63036de16
Adding support for variable type compatibility check after drag and drop
lbessard
parents:
102
diff
changeset
|
1443 |
if self.Mode != MODE_SELECTION and not self.SavedMode: |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
1444 |
wx.CallAfter(self.ParentWindow.ResetCurrentMode) |
0 | 1445 |
event.Skip() |
1446 |
||
319 | 1447 |
def OnViewerMiddleDown(self, event): |
1448 |
self.StartMousePos = event.GetPosition() |
|
1449 |
self.StartScreenPos = self.GetScrollPos(wx.HORIZONTAL), self.GetScrollPos(wx.VERTICAL) |
|
1450 |
event.Skip() |
|
1451 |
||
1452 |
def OnViewerMiddleUp(self, event): |
|
1453 |
self.StartMousePos = None |
|
1454 |
self.StartScreenPos = None |
|
1455 |
event.Skip() |
|
1456 |
||
145 | 1457 |
def OnViewerRightDown(self, event): |
1458 |
if self.Mode == MODE_SELECTION: |
|
1459 |
dc = self.GetLogicalDC() |
|
1460 |
pos = event.GetLogicalPosition(dc) |
|
1461 |
element = self.FindElement(pos) |
|
249 | 1462 |
if self.SelectedElement is not None and self.SelectedElement != element: |
145 | 1463 |
self.SelectedElement.SetSelected(False) |
1464 |
self.SelectedElement = None |
|
1465 |
if element: |
|
1466 |
self.SelectedElement = element |
|
249 | 1467 |
if self.Debug: |
1468 |
Graphic_Element.OnRightDown(self.SelectedElement, event, dc, self.Scaling) |
|
1469 |
else: |
|
1470 |
self.SelectedElement.OnRightDown(event, dc, self.Scaling) |
|
145 | 1471 |
self.SelectedElement.Refresh() |
1472 |
event.Skip() |
|
1473 |
||
0 | 1474 |
def OnViewerRightUp(self, event): |
80 | 1475 |
dc = self.GetLogicalDC() |
249 | 1476 |
if self.SelectedElement is not None: |
1477 |
if self.Debug: |
|
1478 |
Graphic_Element.OnRightUp(self.SelectedElement, event, dc, self.Scaling) |
|
1479 |
else: |
|
1480 |
self.SelectedElement.OnRightUp(event, dc, self.Scaling) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1481 |
wx.CallAfter(self.SetCursor, wx.NullCursor) |
249 | 1482 |
elif not self.Debug: |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1483 |
self.PopupDefaultMenu(False) |
0 | 1484 |
event.Skip() |
1485 |
||
1486 |
def OnViewerLeftDClick(self, event): |
|
249 | 1487 |
if self.Mode == MODE_SELECTION and self.SelectedElement is not None: |
1488 |
if self.Debug: |
|
1489 |
Graphic_Element.OnLeftDClick(self.SelectedElement, event, self.GetLogicalDC(), self.Scaling) |
|
1490 |
elif event.ControlDown() and self.IsBlock(self.SelectedElement) and self.SelectedElement.GetType() in self.Controler.GetProjectPouNames(self.Debug): |
|
102
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
1491 |
self.ParentWindow.EditProjectElement(ITEM_POU, self.SelectedElement.GetType()) |
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
1492 |
else: |
85875dcb7754
Adding edit user's POU by double click on block instance
lbessard
parents:
98
diff
changeset
|
1493 |
self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling) |
0 | 1494 |
event.Skip() |
1495 |
||
1496 |
def OnViewerMotion(self, event): |
|
140
06d28f03f6f4
Adding highlighting on group or element when mouse is over
lbessard
parents:
138
diff
changeset
|
1497 |
refresh = False |
06d28f03f6f4
Adding highlighting on group or element when mouse is over
lbessard
parents:
138
diff
changeset
|
1498 |
dc = self.GetLogicalDC() |
06d28f03f6f4
Adding highlighting on group or element when mouse is over
lbessard
parents:
138
diff
changeset
|
1499 |
pos = GetScaledEventPosition(event, dc, self.Scaling) |
323 | 1500 |
if event.MiddleIsDown(): |
1501 |
if self.StartMousePos is not None and self.StartScreenPos is not None: |
|
1502 |
new_pos = event.GetPosition() |
|
1503 |
xmax = self.GetScrollRange(wx.HORIZONTAL) - self.GetScrollThumb(wx.HORIZONTAL) |
|
1504 |
ymax = self.GetScrollRange(wx.VERTICAL) - self.GetScrollThumb(wx.VERTICAL) |
|
1505 |
scrollx = max(0, self.StartScreenPos[0] + (new_pos[0] - self.StartMousePos[0]) * self.ViewScale[0] / SCROLLBAR_UNIT) |
|
1506 |
scrolly = max(0, self.StartScreenPos[1] + (new_pos[1] - self.StartMousePos[1]) * self.ViewScale[1] / SCROLLBAR_UNIT) |
|
1507 |
if scrollx > xmax or scrolly > ymax: |
|
1508 |
self.RefreshScrollBars(max(0, scrollx - xmax), max(0, scrolly - ymax)) |
|
1509 |
self.Scroll(scrollx, scrolly) |
|
1510 |
else: |
|
1511 |
self.Scroll(scrollx, scrolly) |
|
1512 |
self.RefreshScrollBars() |
|
1513 |
self.RefreshVisibleElements() |
|
1514 |
else: |
|
319 | 1515 |
if not event.Dragging(): |
1516 |
highlighted = self.FindElement(pos) |
|
1517 |
if self.HighlightedElement is not None and self.HighlightedElement != highlighted: |
|
1518 |
self.HighlightedElement.SetHighlighted(False) |
|
1519 |
self.HighlightedElement = None |
|
1520 |
if highlighted is not None and self.HighlightedElement != highlighted: |
|
1521 |
highlighted.SetHighlighted(True) |
|
1522 |
self.HighlightedElement = highlighted |
|
1523 |
if self.rubberBand.IsShown(): |
|
1524 |
self.rubberBand.OnMotion(event, dc, self.Scaling) |
|
1525 |
elif not self.Debug and self.Mode == MODE_SELECTION and self.SelectedElement is not None: |
|
1526 |
if self.DrawingWire: |
|
1527 |
connector = self.FindBlockConnector(pos, self.SelectedElement.GetConnectionDirection(), self.SelectedElement.EndConnected) |
|
1528 |
if not connector or self.SelectedElement.EndConnected == None: |
|
1529 |
self.SelectedElement.ResetPoints() |
|
1530 |
movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling) |
|
1531 |
self.SelectedElement.GeneratePoints() |
|
1532 |
if movex != 0 or movey != 0: |
|
1533 |
self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(movex, movey)), False) |
|
1534 |
else: |
|
144 | 1535 |
movex, movey = self.SelectedElement.OnMotion(event, dc, self.Scaling) |
1536 |
if movex != 0 or movey != 0: |
|
155 | 1537 |
self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(movex, movey)), False) |
319 | 1538 |
self.UpdateScrollPos(event) |
140
06d28f03f6f4
Adding highlighting on group or element when mouse is over
lbessard
parents:
138
diff
changeset
|
1539 |
event.Skip() |
06d28f03f6f4
Adding highlighting on group or element when mouse is over
lbessard
parents:
138
diff
changeset
|
1540 |
|
06d28f03f6f4
Adding highlighting on group or element when mouse is over
lbessard
parents:
138
diff
changeset
|
1541 |
def OnLeaveViewer(self, event): |
249 | 1542 |
if self.SelectedElement is not None and self.SelectedElement.GetDragging(): |
144 | 1543 |
event.Skip() |
1544 |
elif self.HighlightedElement is not None: |
|
140
06d28f03f6f4
Adding highlighting on group or element when mouse is over
lbessard
parents:
138
diff
changeset
|
1545 |
self.HighlightedElement.SetHighlighted(False) |
06d28f03f6f4
Adding highlighting on group or element when mouse is over
lbessard
parents:
138
diff
changeset
|
1546 |
self.HighlightedElement = None |
71 | 1547 |
event.Skip() |
1548 |
||
1549 |
def UpdateScrollPos(self, event): |
|
249 | 1550 |
if (event.Dragging() and self.SelectedElement is not None) or self.rubberBand.IsShown(): |
27 | 1551 |
position = event.GetPosition() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1552 |
move_window = wx.Point() |
27 | 1553 |
window_size = self.GetClientSize() |
1554 |
xstart, ystart = self.GetViewStart() |
|
1555 |
if position.x < SCROLL_ZONE and xstart > 0: |
|
1556 |
move_window.x = -1 |
|
1557 |
elif position.x > window_size[0] - SCROLL_ZONE: |
|
1558 |
move_window.x = 1 |
|
1559 |
if position.y < SCROLL_ZONE and ystart > 0: |
|
1560 |
move_window.y = -1 |
|
1561 |
elif position.y > window_size[1] - SCROLL_ZONE: |
|
1562 |
move_window.y = 1 |
|
1563 |
if move_window.x != 0 or move_window.y != 0: |
|
267 | 1564 |
self.RefreshVisibleElements(xp = xstart + move_window.x, yp = ystart + move_window.y) |
27 | 1565 |
self.Scroll(xstart + move_window.x, ystart + move_window.y) |
42 | 1566 |
self.RefreshScrollBars() |
0 | 1567 |
|
1568 |
#------------------------------------------------------------------------------- |
|
1569 |
# Keyboard event functions |
|
1570 |
#------------------------------------------------------------------------------- |
|
1571 |
||
1572 |
def OnChar(self, event): |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1573 |
xpos, ypos = self.GetScrollPos(wx.HORIZONTAL), self.GetScrollPos(wx.VERTICAL) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1574 |
xmax = self.GetScrollRange(wx.HORIZONTAL) - self.GetScrollThumb(wx.HORIZONTAL) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1575 |
ymax = self.GetScrollRange(wx.VERTICAL) - self.GetScrollThumb(wx.VERTICAL) |
27 | 1576 |
keycode = event.GetKeyCode() |
249 | 1577 |
if self.Scaling is not None: |
27 | 1578 |
scaling = self.Scaling |
1579 |
else: |
|
1580 |
scaling = (8, 8) |
|
249 | 1581 |
if not self.Debug and keycode == wx.WXK_DELETE and self.SelectedElement is not None: |
144 | 1582 |
rect = self.SelectedElement.GetRedrawRect(1, 1) |
27 | 1583 |
self.SelectedElement.Delete() |
1584 |
self.SelectedElement = None |
|
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1585 |
self.RefreshBuffer() |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1586 |
self.RefreshScrollBars() |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1587 |
self.SetCursor(wx.NullCursor) |
155 | 1588 |
self.RefreshRect(self.GetScrolledRect(rect), False) |
249 | 1589 |
elif not self.Debug and keycode == wx.WXK_RETURN and self.SelectedElement is not None: |
138
9c74d00ce93e
Last bugs on block and wire moving, resizing with cursor fixed
lbessard
parents:
128
diff
changeset
|
1590 |
self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1591 |
elif keycode == wx.WXK_LEFT: |
42 | 1592 |
if event.ControlDown() and event.ShiftDown(): |
1593 |
self.Scroll(0, ypos) |
|
319 | 1594 |
self.RefreshVisibleElements() |
42 | 1595 |
elif event.ControlDown(): |
319 | 1596 |
self.Scroll(xpos - 1, ypos) |
1597 |
self.RefreshScrollBars() |
|
1598 |
self.RefreshVisibleElements() |
|
249 | 1599 |
elif not self.Debug and self.SelectedElement is not None: |
42 | 1600 |
self.SelectedElement.Move(-scaling[0], 0) |
67
3a1b0afdaf84
Adding support for automatically generate function blocks in interface when a block is added
lbessard
parents:
64
diff
changeset
|
1601 |
self.SelectedElement.RefreshModel() |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1602 |
self.RefreshBuffer() |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1603 |
self.RefreshScrollBars() |
155 | 1604 |
self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(-scaling[0], 0)), False) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1605 |
elif keycode == wx.WXK_RIGHT: |
42 | 1606 |
if event.ControlDown() and event.ShiftDown(): |
1607 |
self.Scroll(xmax, ypos) |
|
319 | 1608 |
self.RefreshVisibleElements() |
42 | 1609 |
elif event.ControlDown(): |
319 | 1610 |
self.RefreshScrollBars(width_incr=max(0, xpos + 1 - xmax)) |
1611 |
self.Scroll(xpos + 1, ypos) |
|
1612 |
self.RefreshVisibleElements() |
|
249 | 1613 |
elif not self.Debug and self.SelectedElement is not None: |
42 | 1614 |
self.SelectedElement.Move(scaling[0], 0) |
67
3a1b0afdaf84
Adding support for automatically generate function blocks in interface when a block is added
lbessard
parents:
64
diff
changeset
|
1615 |
self.SelectedElement.RefreshModel() |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1616 |
self.RefreshBuffer() |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1617 |
self.RefreshScrollBars() |
155 | 1618 |
self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(scaling[0], 0)), False) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1619 |
elif keycode == wx.WXK_UP: |
42 | 1620 |
if event.ControlDown() and event.ShiftDown(): |
1621 |
self.Scroll(xpos, 0) |
|
319 | 1622 |
self.RefreshVisibleElements() |
42 | 1623 |
elif event.ControlDown(): |
319 | 1624 |
self.Scroll(xpos, ypos - 1) |
1625 |
self.RefreshScrollBars() |
|
1626 |
self.RefreshVisibleElements() |
|
249 | 1627 |
elif not self.Debug and self.SelectedElement is not None: |
42 | 1628 |
self.SelectedElement.Move(0, -scaling[1]) |
67
3a1b0afdaf84
Adding support for automatically generate function blocks in interface when a block is added
lbessard
parents:
64
diff
changeset
|
1629 |
self.SelectedElement.RefreshModel() |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1630 |
self.RefreshBuffer() |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1631 |
self.RefreshScrollBars() |
155 | 1632 |
self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, -scaling[1])), False) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1633 |
elif keycode == wx.WXK_DOWN: |
42 | 1634 |
if event.ControlDown() and event.ShiftDown(): |
1635 |
self.Scroll(xpos, ymax) |
|
319 | 1636 |
self.RefreshVisibleElements() |
42 | 1637 |
elif event.ControlDown(): |
319 | 1638 |
self.RefreshScrollBars(height_incr=max(0, ypos + 1 - ymax)) |
1639 |
self.Scroll(xpos, ypos + 1) |
|
1640 |
self.RefreshVisibleElements() |
|
249 | 1641 |
elif not self.Debug and self.SelectedElement is not None: |
42 | 1642 |
self.SelectedElement.Move(0, scaling[1]) |
67
3a1b0afdaf84
Adding support for automatically generate function blocks in interface when a block is added
lbessard
parents:
64
diff
changeset
|
1643 |
self.SelectedElement.RefreshModel() |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1644 |
self.RefreshBuffer() |
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1645 |
self.RefreshScrollBars() |
155 | 1646 |
self.RefreshRect(self.GetScrolledRect(self.SelectedElement.GetRedrawRect(0, scaling[1])), False) |
249 | 1647 |
elif not self.Debug and keycode == wx.WXK_SPACE and self.SelectedElement is not None and self.SelectedElement.Dragging: |
216
93af9ac5aeaf
Not connecting wire on scaled graphics bug and forbidding copy on the fly of groups fixed
lbessard
parents:
213
diff
changeset
|
1648 |
if self.IsBlock(self.SelectedElement) or self.IsComment(self.SelectedElement): |
93af9ac5aeaf
Not connecting wire on scaled graphics bug and forbidding copy on the fly of groups fixed
lbessard
parents:
213
diff
changeset
|
1649 |
self.CopyBlock(self.SelectedElement, wx.Point(*self.SelectedElement.GetPosition())) |
93af9ac5aeaf
Not connecting wire on scaled graphics bug and forbidding copy on the fly of groups fixed
lbessard
parents:
213
diff
changeset
|
1650 |
self.RefreshBuffer() |
93af9ac5aeaf
Not connecting wire on scaled graphics bug and forbidding copy on the fly of groups fixed
lbessard
parents:
213
diff
changeset
|
1651 |
self.RefreshScrollBars() |
93af9ac5aeaf
Not connecting wire on scaled graphics bug and forbidding copy on the fly of groups fixed
lbessard
parents:
213
diff
changeset
|
1652 |
self.ParentWindow.RefreshVariablePanel(self.TagName) |
267 | 1653 |
self.RefreshVisibleElements() |
216
93af9ac5aeaf
Not connecting wire on scaled graphics bug and forbidding copy on the fly of groups fixed
lbessard
parents:
213
diff
changeset
|
1654 |
self.SelectedElement.Refresh() |
93af9ac5aeaf
Not connecting wire on scaled graphics bug and forbidding copy on the fly of groups fixed
lbessard
parents:
213
diff
changeset
|
1655 |
else: |
93af9ac5aeaf
Not connecting wire on scaled graphics bug and forbidding copy on the fly of groups fixed
lbessard
parents:
213
diff
changeset
|
1656 |
event.Skip() |
97 | 1657 |
else: |
1658 |
event.Skip() |
|
27 | 1659 |
|
1660 |
#------------------------------------------------------------------------------- |
|
1661 |
# Model adding functions |
|
1662 |
#------------------------------------------------------------------------------- |
|
1663 |
||
145 | 1664 |
def GetScaledSize(self, width, height): |
1665 |
if self.Scaling is not None: |
|
1666 |
width = round(float(width) / float(self.Scaling[0]) + 0.4) * self.Scaling[0] |
|
1667 |
height = round(float(height) / float(self.Scaling[1]) + 0.4) * self.Scaling[1] |
|
1668 |
return width, height |
|
1669 |
||
27 | 1670 |
def AddNewBlock(self, bbox): |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1671 |
dialog = BlockPropertiesDialog(self.ParentWindow, self.Controler) |
165 | 1672 |
dialog.SetPreviewFont(self.GetFont()) |
249 | 1673 |
dialog.SetBlockList(self.Controler.GetBlockTypes(self.TagName, self.Debug)) |
1674 |
dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug)) |
|
1675 |
dialog.SetPouElementNames(self.Controler.GetEditedElementVariables(self.TagName, self.Debug)) |
|
27 | 1676 |
dialog.SetMinBlockSize((bbox.width, bbox.height)) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1677 |
if dialog.ShowModal() == wx.ID_OK: |
27 | 1678 |
id = self.GetNewId() |
1679 |
values = dialog.GetValues() |
|
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
1680 |
values.setdefault("name", "") |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
1681 |
block = FBD_Block(self, values["type"], values["name"], id, |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
1682 |
values["extension"], values["inputs"], |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
1683 |
executionControl = values["executionControl"], |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
1684 |
executionOrder = values["executionOrder"]) |
27 | 1685 |
block.SetPosition(bbox.x, bbox.y) |
145 | 1686 |
block.SetSize(*self.GetScaledSize(values["width"], values["height"])) |
42 | 1687 |
self.AddBlock(block) |
121 | 1688 |
self.Controler.AddEditedElementBlock(self.TagName, id, values["type"], values.get("name", None)) |
27 | 1689 |
self.RefreshBlockModel(block) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1690 |
self.RefreshBuffer() |
42 | 1691 |
self.RefreshScrollBars() |
249 | 1692 |
self.RefreshVisibleElements() |
144 | 1693 |
self.ParentWindow.RefreshVariablePanel(self.TagName) |
239
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
1694 |
self.ParentWindow.RefreshInstancesTree() |
144 | 1695 |
block.Refresh() |
27 | 1696 |
dialog.Destroy() |
1697 |
||
1698 |
def AddNewVariable(self, bbox): |
|
253 | 1699 |
words = self.TagName.split("::") |
1700 |
if words[0] == "T": |
|
1701 |
dialog = VariablePropertiesDialog(self.ParentWindow, self.Controler, words[2]) |
|
1702 |
else: |
|
1703 |
dialog = VariablePropertiesDialog(self.ParentWindow, self.Controler) |
|
165 | 1704 |
dialog.SetPreviewFont(self.GetFont()) |
27 | 1705 |
dialog.SetMinVariableSize((bbox.width, bbox.height)) |
1706 |
varlist = [] |
|
249 | 1707 |
vars = self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug) |
27 | 1708 |
if vars: |
1709 |
for var in vars: |
|
70 | 1710 |
if var["Edit"]: |
1711 |
varlist.append((var["Name"], var["Class"], var["Type"])) |
|
249 | 1712 |
returntype = self.Controler.GetEditedElementInterfaceReturnType(self.TagName, self.Debug) |
27 | 1713 |
if returntype: |
121 | 1714 |
varlist.append((self.Controler.GetEditedElementName(self.TagName), "Output", returntype)) |
27 | 1715 |
dialog.SetVariables(varlist) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1716 |
if dialog.ShowModal() == wx.ID_OK: |
27 | 1717 |
id = self.GetNewId() |
1718 |
values = dialog.GetValues() |
|
1719 |
variable = FBD_Variable(self, values["type"], values["name"], values["value_type"], id) |
|
1720 |
variable.SetPosition(bbox.x, bbox.y) |
|
145 | 1721 |
variable.SetSize(*self.GetScaledSize(values["width"], values["height"])) |
42 | 1722 |
self.AddBlock(variable) |
121 | 1723 |
self.Controler.AddEditedElementVariable(self.TagName, id, values["type"]) |
27 | 1724 |
self.RefreshVariableModel(variable) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1725 |
self.RefreshBuffer() |
42 | 1726 |
self.RefreshScrollBars() |
249 | 1727 |
self.RefreshVisibleElements() |
144 | 1728 |
variable.Refresh() |
27 | 1729 |
dialog.Destroy() |
1730 |
||
1731 |
def AddNewConnection(self, bbox): |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1732 |
dialog = ConnectionPropertiesDialog(self.ParentWindow, self.Controler) |
165 | 1733 |
dialog.SetPreviewFont(self.GetFont()) |
27 | 1734 |
dialog.SetMinConnectionSize((bbox.width, bbox.height)) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1735 |
if dialog.ShowModal() == wx.ID_OK: |
27 | 1736 |
id = self.GetNewId() |
1737 |
values = dialog.GetValues() |
|
1738 |
connection = FBD_Connector(self, values["type"], values["name"], id) |
|
1739 |
connection.SetPosition(bbox.x, bbox.y) |
|
145 | 1740 |
connection.SetSize(*self.GetScaledSize(values["width"], values["height"])) |
42 | 1741 |
self.AddBlock(connection) |
121 | 1742 |
self.Controler.AddEditedElementConnection(self.TagName, id, values["type"]) |
27 | 1743 |
self.RefreshConnectionModel(connection) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1744 |
self.RefreshBuffer() |
42 | 1745 |
self.RefreshScrollBars() |
249 | 1746 |
self.RefreshVisibleElements() |
144 | 1747 |
connection.Refresh() |
27 | 1748 |
dialog.Destroy() |
1749 |
||
1750 |
def AddNewComment(self, bbox): |
|
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
1751 |
if wx.VERSION >= (2, 5, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
1752 |
dialog = wx.TextEntryDialog(self.ParentWindow, "Edit comment", "Please enter comment text", "", wx.OK|wx.CANCEL|wx.TE_MULTILINE) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
1753 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
1754 |
dialog = wx.TextEntryDialog(self.ParentWindow, "Edit comment", "Please enter comment text", "", wx.OK|wx.CANCEL) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1755 |
if dialog.ShowModal() == wx.ID_OK: |
27 | 1756 |
value = dialog.GetValue() |
1757 |
id = self.GetNewId() |
|
1758 |
comment = Comment(self, value, id) |
|
1759 |
comment.SetPosition(bbox.x, bbox.y) |
|
1760 |
min_width, min_height = comment.GetMinSize() |
|
145 | 1761 |
comment.SetSize(*self.GetScaledSize(max(min_width,bbox.width),max(min_height,bbox.height))) |
42 | 1762 |
self.AddComment(comment) |
121 | 1763 |
self.Controler.AddEditedElementComment(self.TagName, id) |
27 | 1764 |
self.RefreshCommentModel(comment) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1765 |
self.RefreshBuffer() |
42 | 1766 |
self.RefreshScrollBars() |
249 | 1767 |
self.RefreshVisibleElements() |
144 | 1768 |
comment.Refresh() |
27 | 1769 |
dialog.Destroy() |
1770 |
||
1771 |
def AddNewContact(self, bbox): |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1772 |
dialog = LDElementDialog(self.ParentWindow, self.Controler, "contact") |
165 | 1773 |
dialog.SetPreviewFont(self.GetFont()) |
27 | 1774 |
varlist = [] |
249 | 1775 |
vars = self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug) |
27 | 1776 |
if vars: |
1777 |
for var in vars: |
|
277
5fc11b2d4fbb
Bug in contact edition not allowing output referencing fixed
lbessard
parents:
275
diff
changeset
|
1778 |
if var["Type"] == "BOOL": |
27 | 1779 |
varlist.append(var["Name"]) |
1780 |
dialog.SetVariables(varlist) |
|
1781 |
dialog.SetValues({"name":"","type":CONTACT_NORMAL}) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1782 |
dialog.SetElementSize((bbox.width, bbox.height)) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1783 |
if dialog.ShowModal() == wx.ID_OK: |
27 | 1784 |
id = self.GetNewId() |
1785 |
values = dialog.GetValues() |
|
1786 |
contact = LD_Contact(self, values["type"], values["name"], id) |
|
1787 |
contact.SetPosition(bbox.x, bbox.y) |
|
145 | 1788 |
contact.SetSize(*self.GetScaledSize(values["width"], values["height"])) |
42 | 1789 |
self.AddBlock(contact) |
121 | 1790 |
self.Controler.AddEditedElementContact(self.TagName, id) |
27 | 1791 |
self.RefreshContactModel(contact) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1792 |
self.RefreshBuffer() |
42 | 1793 |
self.RefreshScrollBars() |
249 | 1794 |
self.RefreshVisibleElements() |
144 | 1795 |
contact.Refresh() |
27 | 1796 |
dialog.Destroy() |
1797 |
||
1798 |
def AddNewCoil(self, bbox): |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1799 |
dialog = LDElementDialog(self.ParentWindow, self.Controler, "coil") |
165 | 1800 |
dialog.SetPreviewFont(self.GetFont()) |
27 | 1801 |
varlist = [] |
249 | 1802 |
vars = self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug) |
27 | 1803 |
if vars: |
1804 |
for var in vars: |
|
1805 |
if var["Class"] != "Input" and var["Type"] == "BOOL": |
|
1806 |
varlist.append(var["Name"]) |
|
249 | 1807 |
returntype = self.Controler.GetEditedElementInterfaceReturnType(self.TagName, self.Debug) |
27 | 1808 |
if returntype == "BOOL": |
121 | 1809 |
varlist.append(self.Controler.GetEditedElementName(self.TagName)) |
27 | 1810 |
dialog.SetVariables(varlist) |
1811 |
dialog.SetValues({"name":"","type":COIL_NORMAL}) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1812 |
dialog.SetElementSize((bbox.width, bbox.height)) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1813 |
if dialog.ShowModal() == wx.ID_OK: |
27 | 1814 |
id = self.GetNewId() |
1815 |
values = dialog.GetValues() |
|
1816 |
coil = LD_Coil(self, values["type"], values["name"], id) |
|
1817 |
coil.SetPosition(bbox.x, bbox.y) |
|
145 | 1818 |
coil.SetSize(*self.GetScaledSize(values["width"], values["height"])) |
42 | 1819 |
self.AddBlock(coil) |
121 | 1820 |
self.Controler.AddEditedElementCoil(self.TagName, id) |
67
3a1b0afdaf84
Adding support for automatically generate function blocks in interface when a block is added
lbessard
parents:
64
diff
changeset
|
1821 |
self.RefreshCoilModel(coil) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1822 |
self.RefreshBuffer() |
42 | 1823 |
self.RefreshScrollBars() |
249 | 1824 |
self.RefreshVisibleElements() |
144 | 1825 |
coil.Refresh() |
27 | 1826 |
dialog.Destroy() |
1827 |
||
1828 |
def AddNewPowerRail(self, bbox): |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1829 |
dialog = LDPowerRailDialog(self.ParentWindow, self.Controler) |
165 | 1830 |
dialog.SetPreviewFont(self.GetFont()) |
27 | 1831 |
dialog.SetMinSize((bbox.width, bbox.height)) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1832 |
if dialog.ShowModal() == wx.ID_OK: |
27 | 1833 |
id = self.GetNewId() |
1834 |
values = dialog.GetValues() |
|
1835 |
powerrail = LD_PowerRail(self, values["type"], id, [True for i in xrange(values["number"])]) |
|
1836 |
powerrail.SetPosition(bbox.x, bbox.y) |
|
145 | 1837 |
powerrail.SetSize(*self.GetScaledSize(values["width"], values["height"])) |
42 | 1838 |
self.AddBlock(powerrail) |
121 | 1839 |
self.Controler.AddEditedElementPowerRail(self.TagName, id, values["type"]) |
27 | 1840 |
self.RefreshPowerRailModel(powerrail) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1841 |
self.RefreshBuffer() |
42 | 1842 |
self.RefreshScrollBars() |
249 | 1843 |
self.RefreshVisibleElements() |
144 | 1844 |
powerrail.Refresh() |
27 | 1845 |
dialog.Destroy() |
1846 |
||
71 | 1847 |
def AddNewStep(self, bbox, initial = False): |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1848 |
dialog = StepContentDialog(self.ParentWindow, self.Controler, initial) |
165 | 1849 |
dialog.SetPreviewFont(self.GetFont()) |
249 | 1850 |
dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug)) |
1851 |
dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug)) |
|
71 | 1852 |
dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)]) |
1853 |
dialog.SetMinStepSize((bbox.width, bbox.height)) |
|
1854 |
if dialog.ShowModal() == wx.ID_OK: |
|
1855 |
id = self.GetNewId() |
|
1856 |
values = dialog.GetValues() |
|
1857 |
step = SFC_Step(self, values["name"], initial, id) |
|
1858 |
if values["input"]: |
|
1859 |
step.AddInput() |
|
1860 |
else: |
|
1861 |
step.RemoveInput() |
|
1862 |
if values["output"]: |
|
1863 |
step.AddOutput() |
|
1864 |
else: |
|
1865 |
step.RemoveOutput() |
|
1866 |
if values["action"]: |
|
1867 |
step.AddAction() |
|
1868 |
else: |
|
1869 |
step.RemoveAction() |
|
1870 |
step.SetPosition(bbox.x, bbox.y) |
|
1871 |
min_width, min_height = step.GetMinSize() |
|
145 | 1872 |
step.SetSize(*self.GetScaledSize(max(bbox.width, min_width), max(bbox.height, min_height))) |
71 | 1873 |
self.AddBlock(step) |
121 | 1874 |
self.Controler.AddEditedElementStep(self.TagName, id) |
71 | 1875 |
self.RefreshStepModel(step) |
1876 |
self.RefreshBuffer() |
|
1877 |
self.RefreshScrollBars() |
|
249 | 1878 |
self.RefreshVisibleElements() |
144 | 1879 |
step.Refresh() |
71 | 1880 |
dialog.Destroy() |
1881 |
||
27 | 1882 |
def AddNewTransition(self, bbox): |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1883 |
dialog = TransitionContentDialog(self.ParentWindow, self.Controler, self.GetDrawingMode() == FREEDRAWING_MODE) |
165 | 1884 |
dialog.SetPreviewFont(self.GetFont()) |
249 | 1885 |
dialog.SetTransitions(self.Controler.GetEditedElementTransitions(self.TagName, self.Debug)) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1886 |
if dialog.ShowModal() == wx.ID_OK: |
27 | 1887 |
id = self.GetNewId() |
1888 |
values = dialog.GetValues() |
|
80 | 1889 |
transition = SFC_Transition(self, values["type"], values["value"], values["priority"], id) |
27 | 1890 |
transition.SetPosition(bbox.x, bbox.y) |
1891 |
min_width, min_height = transition.GetMinSize() |
|
145 | 1892 |
transition.SetSize(*self.GetScaledSize(max(bbox.width, min_width), max(bbox.height, min_height))) |
42 | 1893 |
self.AddBlock(transition) |
121 | 1894 |
self.Controler.AddEditedElementTransition(self.TagName, id) |
27 | 1895 |
self.RefreshTransitionModel(transition) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1896 |
self.RefreshBuffer() |
42 | 1897 |
self.RefreshScrollBars() |
249 | 1898 |
self.RefreshVisibleElements() |
144 | 1899 |
transition.Refresh() |
27 | 1900 |
dialog.Destroy() |
1901 |
||
1902 |
def AddNewDivergence(self, bbox): |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1903 |
dialog = DivergenceCreateDialog(self.ParentWindow, self.Controler) |
165 | 1904 |
dialog.SetPreviewFont(self.GetFont()) |
27 | 1905 |
dialog.SetMinSize((bbox.width, bbox.height)) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
1906 |
if dialog.ShowModal() == wx.ID_OK: |
27 | 1907 |
id = self.GetNewId() |
1908 |
values = dialog.GetValues() |
|
1909 |
divergence = SFC_Divergence(self, values["type"], values["number"], id) |
|
1910 |
divergence.SetPosition(bbox.x, bbox.y) |
|
111 | 1911 |
min_width, min_height = divergence.GetMinSize(True) |
145 | 1912 |
divergence.SetSize(*self.GetScaledSize(max(bbox.width, min_width), max(bbox.height, min_height))) |
42 | 1913 |
self.AddBlock(divergence) |
121 | 1914 |
self.Controler.AddEditedElementDivergence(self.TagName, id, values["type"]) |
27 | 1915 |
self.RefreshDivergenceModel(divergence) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1916 |
self.RefreshBuffer() |
42 | 1917 |
self.RefreshScrollBars() |
249 | 1918 |
self.RefreshVisibleElements() |
144 | 1919 |
divergence.Refresh() |
27 | 1920 |
dialog.Destroy() |
0 | 1921 |
|
108 | 1922 |
def AddNewJump(self, bbox): |
1923 |
choices = [] |
|
1924 |
for block in self.Blocks: |
|
1925 |
if isinstance(block, SFC_Step): |
|
1926 |
choices.append(block.GetName()) |
|
1927 |
dialog = wx.SingleChoiceDialog(self.ParentWindow, "Add a new jump", "Please choose a target", choices, wx.OK|wx.CANCEL) |
|
1928 |
if dialog.ShowModal() == wx.ID_OK: |
|
1929 |
id = self.GetNewId() |
|
1930 |
value = dialog.GetStringSelection() |
|
1931 |
jump = SFC_Jump(self, value, id) |
|
1932 |
jump.SetPosition(bbox.x, bbox.y) |
|
1933 |
min_width, min_height = jump.GetMinSize() |
|
145 | 1934 |
jump.SetSize(*self.GetScaledSize(max(bbox.width, min_width), max(bbox.height, min_height))) |
108 | 1935 |
self.AddBlock(jump) |
121 | 1936 |
self.Controler.AddEditedElementJump(self.TagName, id) |
108 | 1937 |
self.RefreshJumpModel(jump) |
1938 |
self.RefreshBuffer() |
|
1939 |
self.RefreshScrollBars() |
|
249 | 1940 |
self.RefreshVisibleElements() |
144 | 1941 |
jump.Refresh() |
108 | 1942 |
dialog.Destroy() |
1943 |
||
1944 |
def AddNewActionBlock(self, bbox): |
|
1945 |
dialog = ActionBlockDialog(self.ParentWindow) |
|
1946 |
dialog.SetQualifierList(self.Controler.GetQualifierTypes()) |
|
249 | 1947 |
dialog.SetActionList(self.Controler.GetEditedElementActions(self.TagName, self.Debug)) |
1948 |
dialog.SetVariableList(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug)) |
|
108 | 1949 |
if dialog.ShowModal() == wx.ID_OK: |
1950 |
actions = dialog.GetValues() |
|
1951 |
id = self.GetNewId() |
|
1952 |
actionblock = SFC_ActionBlock(self, actions, id) |
|
1953 |
actionblock.SetPosition(bbox.x, bbox.y) |
|
1954 |
min_width, min_height = actionblock.GetMinSize() |
|
145 | 1955 |
actionblock.SetSize(*self.GetScaledSize(max(bbox.width, min_width), max(bbox.height, min_height))) |
108 | 1956 |
self.AddBlock(actionblock) |
121 | 1957 |
self.Controler.AddEditedElementActionBlock(self.TagName, id) |
108 | 1958 |
self.RefreshActionBlockModel(actionblock) |
1959 |
self.RefreshBuffer() |
|
1960 |
self.RefreshScrollBars() |
|
249 | 1961 |
self.RefreshVisibleElements() |
144 | 1962 |
actionblock.Refresh() |
108 | 1963 |
dialog.Destroy() |
27 | 1964 |
|
1965 |
#------------------------------------------------------------------------------- |
|
1966 |
# Edit element content functions |
|
1967 |
#------------------------------------------------------------------------------- |
|
1968 |
||
1969 |
def EditBlockContent(self, block): |
|
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
1970 |
dialog = BlockPropertiesDialog(self.ParentWindow, self.Controler) |
165 | 1971 |
dialog.SetPreviewFont(self.GetFont()) |
249 | 1972 |
dialog.SetBlockList(self.Controler.GetBlockTypes(self.TagName, self.Debug)) |
1973 |
dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug)) |
|
1974 |
variable_names = self.Controler.GetEditedElementVariables(self.TagName, self.Debug) |
|
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1975 |
if block.GetName() != "": |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1976 |
variable_names.remove(block.GetName()) |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1977 |
dialog.SetPouElementNames(variable_names) |
27 | 1978 |
dialog.SetMinBlockSize(block.GetSize()) |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
1979 |
old_values = {"name" : block.GetName(), |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
1980 |
"type" : block.GetType(), |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
1981 |
"extension" : block.GetExtension(), |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
1982 |
"inputs" : block.GetInputTypes(), |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
1983 |
"executionControl" : block.GetExecutionControl(), |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
1984 |
"executionOrder" : block.GetExecutionOrder()} |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1985 |
dialog.SetValues(old_values) |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1986 |
if dialog.ShowModal() == wx.ID_OK: |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1987 |
new_values = dialog.GetValues() |
154 | 1988 |
rect = block.GetRedrawRect(1, 1) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1989 |
if "name" in new_values: |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1990 |
block.SetName(new_values["name"]) |
154 | 1991 |
else: |
1992 |
block.SetName("") |
|
145 | 1993 |
block.SetSize(*self.GetScaledSize(new_values["width"], new_values["height"])) |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
1994 |
block.SetType(new_values["type"], new_values["extension"], executionControl = new_values["executionControl"]) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
1995 |
block.SetExecutionOrder(new_values["executionOrder"]) |
154 | 1996 |
rect = rect.Union(block.GetRedrawRect()) |
27 | 1997 |
self.RefreshBlockModel(block) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
1998 |
self.RefreshBuffer() |
42 | 1999 |
self.RefreshScrollBars() |
249 | 2000 |
self.RefreshVisibleElements() |
144 | 2001 |
self.ParentWindow.RefreshVariablePanel(self.TagName) |
239
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
2002 |
self.ParentWindow.RefreshInstancesTree() |
269
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
2003 |
if old_values["executionOrder"] != new_values["executionOrder"]: |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
2004 |
self.RefreshView() |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
2005 |
else: |
34eff05909b0
Adding support for EN/ENO variables (temporarily disabled, waiting for matiec support)
lbessard
parents:
267
diff
changeset
|
2006 |
block.Refresh(rect) |
27 | 2007 |
dialog.Destroy() |
2008 |
||
2009 |
def EditVariableContent(self, variable): |
|
253 | 2010 |
words = self.TagName.split("::") |
2011 |
if words[0] == "T": |
|
2012 |
dialog = VariablePropertiesDialog(self.ParentWindow, self.Controler, words[2]) |
|
2013 |
else: |
|
2014 |
dialog = VariablePropertiesDialog(self.ParentWindow, self.Controler) |
|
165 | 2015 |
dialog.SetPreviewFont(self.GetFont()) |
27 | 2016 |
dialog.SetMinVariableSize(variable.GetSize()) |
2017 |
varlist = [] |
|
249 | 2018 |
vars = self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug) |
27 | 2019 |
if vars: |
2020 |
for var in vars: |
|
70 | 2021 |
if var["Edit"]: |
2022 |
varlist.append((var["Name"], var["Class"], var["Type"])) |
|
249 | 2023 |
returntype = self.Controler.GetEditedElementInterfaceReturnType(self.TagName, self.Debug) |
27 | 2024 |
if returntype: |
121 | 2025 |
varlist.append((self.Controler.GetEditedElementName(self.TagName), "Output", returntype)) |
27 | 2026 |
dialog.SetVariables(varlist) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2027 |
old_values = {"name" : variable.GetName(), "type" : variable.GetType(), |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2028 |
"executionOrder" : variable.GetExecutionOrder()} |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2029 |
dialog.SetValues(old_values) |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2030 |
if dialog.ShowModal() == wx.ID_OK: |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2031 |
new_values = dialog.GetValues() |
154 | 2032 |
rect = variable.GetRedrawRect(1, 1) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2033 |
variable.SetName(new_values["name"]) |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2034 |
variable.SetType(new_values["type"], new_values["value_type"]) |
145 | 2035 |
variable.SetSize(*self.GetScaledSize(new_values["width"], new_values["height"])) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2036 |
variable.SetExecutionOrder(new_values["executionOrder"]) |
154 | 2037 |
rect = rect.Union(variable.GetRedrawRect()) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2038 |
if old_values["type"] != new_values["type"]: |
27 | 2039 |
id = variable.GetId() |
121 | 2040 |
self.Controler.RemoveEditedElementInstance(self.TagName, id) |
2041 |
self.Controler.AddEditedElementVariable(self.TagName, id, new_values["type"]) |
|
27 | 2042 |
self.RefreshVariableModel(variable) |
118
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2043 |
if old_values["executionOrder"] != new_values["executionOrder"]: |
0c53d6a36013
Add support for defining execution order in FBD networks (related ST code not generated yet)
lbessard
parents:
114
diff
changeset
|
2044 |
self.RefreshView() |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
2045 |
self.RefreshBuffer() |
249 | 2046 |
self.RefreshVisibleElements() |
42 | 2047 |
self.RefreshScrollBars() |
154 | 2048 |
variable.Refresh(rect) |
27 | 2049 |
dialog.Destroy() |
2050 |
||
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2051 |
def EditConnectionContent(self, connection): |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2052 |
dialog = ConnectionPropertiesDialog(self.ParentWindow, self.Controler) |
165 | 2053 |
dialog.SetPreviewFont(self.GetFont()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2054 |
dialog.SetMinConnectionSize(connection.GetSize()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2055 |
values = {"name" : connection.GetName(), "type" : connection.GetType()} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2056 |
dialog.SetValues(values) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2057 |
if dialog.ShowModal() == wx.ID_OK: |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2058 |
old_type = connection.GetType() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2059 |
values = dialog.GetValues() |
154 | 2060 |
rect = connection.GetRedrawRect(1, 1) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2061 |
connection.SetName(values["name"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2062 |
connection.SetType(values["type"]) |
145 | 2063 |
connection.SetSize(*self.GetScaledSize(values["width"], values["height"])) |
154 | 2064 |
rect = rect.Union(connection.GetRedrawRect()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2065 |
if old_type != values["type"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2066 |
id = connection.GetId() |
121 | 2067 |
self.Controler.RemoveEditedElementInstance(self.TagName, id) |
2068 |
self.Controler.AddEditedElementConnection(self.TagName, id, values["type"]) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2069 |
self.RefreshConnectionModel(connection) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
2070 |
self.RefreshBuffer() |
42 | 2071 |
self.RefreshScrollBars() |
249 | 2072 |
self.RefreshVisibleElements() |
154 | 2073 |
connection.Refresh(rect) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2074 |
dialog.Destroy() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2075 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2076 |
def EditContactContent(self, contact): |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2077 |
dialog = LDElementDialog(self.ParentWindow, self.Controler, "contact") |
165 | 2078 |
dialog.SetPreviewFont(self.GetFont()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2079 |
varlist = [] |
249 | 2080 |
vars = self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2081 |
if vars: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2082 |
for var in vars: |
277
5fc11b2d4fbb
Bug in contact edition not allowing output referencing fixed
lbessard
parents:
275
diff
changeset
|
2083 |
if var["Type"] == "BOOL": |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2084 |
varlist.append(var["Name"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2085 |
dialog.SetVariables(varlist) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2086 |
values = {"name" : contact.GetName(), "type" : contact.GetType()} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2087 |
dialog.SetValues(values) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2088 |
dialog.SetElementSize(contact.GetSize()) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2089 |
if dialog.ShowModal() == wx.ID_OK: |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2090 |
values = dialog.GetValues() |
154 | 2091 |
rect = contact.GetRedrawRect(1, 1) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2092 |
contact.SetName(values["name"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2093 |
contact.SetType(values["type"]) |
145 | 2094 |
contact.SetSize(*self.GetScaledSize(values["width"], values["height"])) |
154 | 2095 |
rect = rect.Union(contact.GetRedrawRect()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2096 |
self.RefreshContactModel(contact) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
2097 |
self.RefreshBuffer() |
42 | 2098 |
self.RefreshScrollBars() |
249 | 2099 |
self.RefreshVisibleElements() |
154 | 2100 |
contact.Refresh(rect) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2101 |
dialog.Destroy() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2102 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2103 |
def EditCoilContent(self, coil): |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2104 |
dialog = LDElementDialog(self.ParentWindow, self.Controler, "coil") |
165 | 2105 |
dialog.SetPreviewFont(self.GetFont()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2106 |
varlist = [] |
249 | 2107 |
vars = self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2108 |
if vars: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2109 |
for var in vars: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2110 |
if var["Class"] != "Input" and var["Type"] == "BOOL": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2111 |
varlist.append(var["Name"]) |
249 | 2112 |
returntype = self.Controler.GetEditedElementInterfaceReturnType(self.TagName, self.Debug) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2113 |
if returntype == "BOOL": |
121 | 2114 |
varlist.append(self.Controler.GetEditedElementName(self.TagName)) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2115 |
dialog.SetVariables(varlist) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2116 |
values = {"name" : coil.GetName(), "type" : coil.GetType()} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2117 |
dialog.SetValues(values) |
61
dc7142ae9438
Adding possibility to change Type and Pin number of power rails
lbessard
parents:
58
diff
changeset
|
2118 |
dialog.SetElementSize(coil.GetSize()) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2119 |
if dialog.ShowModal() == wx.ID_OK: |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2120 |
values = dialog.GetValues() |
154 | 2121 |
rect = coil.GetRedrawRect(1, 1) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2122 |
coil.SetName(values["name"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2123 |
coil.SetType(values["type"]) |
145 | 2124 |
coil.SetSize(*self.GetScaledSize(values["width"], values["height"])) |
154 | 2125 |
rect = rect.Union(coil.GetRedrawRect()) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2126 |
self.RefreshCoilModel(coil) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
2127 |
self.RefreshBuffer() |
42 | 2128 |
self.RefreshScrollBars() |
249 | 2129 |
self.RefreshVisibleElements() |
154 | 2130 |
coil.Refresh(rect) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2131 |
dialog.Destroy() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2132 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2133 |
def EditPowerRailContent(self, powerrail): |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2134 |
dialog = LDPowerRailDialog(self.ParentWindow, self.Controler, powerrail.GetType(), len(powerrail.GetConnectors())) |
165 | 2135 |
dialog.SetPreviewFont(self.GetFont()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2136 |
dialog.SetMinSize(powerrail.GetSize()) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2137 |
if dialog.ShowModal() == wx.ID_OK: |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2138 |
old_type = powerrail.GetType() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2139 |
values = dialog.GetValues() |
154 | 2140 |
rect = powerrail.GetRedrawRect(1, 1) |
61
dc7142ae9438
Adding possibility to change Type and Pin number of power rails
lbessard
parents:
58
diff
changeset
|
2141 |
powerrail.SetType(values["type"], [True for i in xrange(values["number"])]) |
145 | 2142 |
powerrail.SetSize(*self.GetScaledSize(values["width"], values["height"])) |
154 | 2143 |
rect = rect.Union(powerrail.GetRedrawRect()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2144 |
if old_type != values["type"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2145 |
id = powerrail.GetId() |
121 | 2146 |
self.Controler.RemoveEditedElementInstance(self.TagName, id) |
2147 |
self.Controler.AddEditedElementPowerRail(self.TagName, id, values["type"]) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2148 |
self.RefreshPowerRailModel(powerrail) |
56
7187e1c00975
Adding support for Undo/Redo and Unsaved File On Close detection
lbessard
parents:
54
diff
changeset
|
2149 |
self.RefreshBuffer() |
42 | 2150 |
self.RefreshScrollBars() |
249 | 2151 |
self.RefreshVisibleElements() |
154 | 2152 |
powerrail.Refresh(rect) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2153 |
dialog.Destroy() |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2154 |
|
71 | 2155 |
def EditStepContent(self, step): |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2156 |
dialog = StepContentDialog(self.ParentWindow, self.Controler, step.GetInitial()) |
165 | 2157 |
dialog.SetPreviewFont(self.GetFont()) |
249 | 2158 |
dialog.SetPouNames(self.Controler.GetProjectPouNames(self.Debug)) |
2159 |
dialog.SetVariables(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug)) |
|
71 | 2160 |
dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()]) |
2161 |
dialog.SetMinStepSize(step.GetSize()) |
|
2162 |
values = {"name" : step.GetName()} |
|
2163 |
connectors = step.GetConnectors() |
|
2164 |
values["input"] = connectors["input"] != None |
|
2165 |
values["output"] = connectors["output"] != None |
|
2166 |
values["action"] = connectors["action"] != None |
|
2167 |
dialog.SetValues(values) |
|
2168 |
if dialog.ShowModal() == wx.ID_OK: |
|
2169 |
values = dialog.GetValues() |
|
154 | 2170 |
rect = step.GetRedrawRect(1, 1) |
71 | 2171 |
step.SetName(values["name"]) |
2172 |
if values["input"]: |
|
2173 |
step.AddInput() |
|
2174 |
else: |
|
2175 |
step.RemoveInput() |
|
2176 |
if values["output"]: |
|
2177 |
step.AddOutput() |
|
2178 |
else: |
|
2179 |
step.RemoveOutput() |
|
2180 |
if values["action"]: |
|
2181 |
step.AddAction() |
|
2182 |
else: |
|
2183 |
step.RemoveAction() |
|
145 | 2184 |
step.UpdateSize(*self.GetScaledSize(values["width"], values["height"])) |
154 | 2185 |
rect = rect.Union(step.GetRedrawRect()) |
2186 |
self.RefreshStepModel(step) |
|
2187 |
self.RefreshBuffer() |
|
2188 |
self.RefreshScrollBars() |
|
249 | 2189 |
self.RefreshVisibleElements() |
154 | 2190 |
step.Refresh(rect) |
71 | 2191 |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2192 |
def EditTransitionContent(self, transition): |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2193 |
dialog = TransitionContentDialog(self.ParentWindow, self.Controler, self.GetDrawingMode() == FREEDRAWING_MODE) |
165 | 2194 |
dialog.SetPreviewFont(self.GetFont()) |
249 | 2195 |
dialog.SetTransitions(self.Controler.GetEditedElementTransitions(self.TagName, self.Debug)) |
80 | 2196 |
dialog.SetValues({"type":transition.GetType(),"value":transition.GetCondition(), "priority":transition.GetPriority()}) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2197 |
dialog.SetElementSize(transition.GetSize()) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2198 |
if dialog.ShowModal() == wx.ID_OK: |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2199 |
values = dialog.GetValues() |
154 | 2200 |
rect = transition.GetRedrawRect(1, 1) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2201 |
transition.SetType(values["type"],values["value"]) |
80 | 2202 |
transition.SetPriority(values["priority"]) |
154 | 2203 |
rect = rect.Union(transition.GetRedrawRect()) |
2204 |
self.RefreshTransitionModel(transition) |
|
2205 |
self.RefreshBuffer() |
|
2206 |
self.RefreshScrollBars() |
|
249 | 2207 |
self.RefreshVisibleElements() |
154 | 2208 |
transition.Refresh(rect) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2209 |
dialog.Destroy() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2210 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2211 |
def EditJumpContent(self, jump): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2212 |
choices = [] |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2213 |
for block in self.Blocks: |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2214 |
if isinstance(block, SFC_Step): |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2215 |
choices.append(block.GetName()) |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
2216 |
dialog = wx.SingleChoiceDialog(self.ParentWindow, "Edit jump target", "Please choose a target", choices, wx.OK|wx.CANCEL) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2217 |
dialog.SetSelection(choices.index(jump.GetTarget())) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2218 |
if dialog.ShowModal() == wx.ID_OK: |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2219 |
value = dialog.GetStringSelection() |
154 | 2220 |
rect = jump.GetRedrawRect(1, 1) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2221 |
jump.SetTarget(value) |
154 | 2222 |
rect = rect.Union(jump.GetRedrawRect()) |
2223 |
self.RefreshJumpModel(jump) |
|
2224 |
self.RefreshBuffer() |
|
2225 |
self.RefreshScrollBars() |
|
249 | 2226 |
self.RefreshVisibleElements() |
154 | 2227 |
jump.Refresh(rect) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2228 |
dialog.Destroy() |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2229 |
|
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2230 |
def EditActionBlockContent(self, actionblock): |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
2231 |
dialog = ActionBlockDialog(self.ParentWindow) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2232 |
dialog.SetQualifierList(self.Controler.GetQualifierTypes()) |
249 | 2233 |
dialog.SetActionList(self.Controler.GetEditedElementActions(self.TagName, self.Debug)) |
2234 |
dialog.SetVariableList(self.Controler.GetEditedElementInterfaceVars(self.TagName, self.Debug)) |
|
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2235 |
dialog.SetValues(actionblock.GetActions()) |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2236 |
if dialog.ShowModal() == wx.ID_OK: |
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2237 |
actions = dialog.GetValues() |
154 | 2238 |
rect = actionblock.GetRedrawRect(1, 1) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2239 |
actionblock.SetActions(actions) |
145 | 2240 |
actionblock.SetSize(*self.GetScaledSize(*actionblock.GetSize())) |
154 | 2241 |
rect = rect.Union(actionblock.GetRedrawRect()) |
2242 |
self.RefreshActionBlockModel(actionblock) |
|
2243 |
self.RefreshBuffer() |
|
2244 |
self.RefreshScrollBars() |
|
249 | 2245 |
self.RefreshVisibleElements() |
154 | 2246 |
actionblock.Refresh(rect) |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
2247 |
dialog.Destroy() |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
2248 |
|
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
2249 |
def EditCommentContent(self, comment): |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2250 |
if wx.VERSION >= (2, 5, 0): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2251 |
dialog = wx.TextEntryDialog(self.ParentWindow, "Edit comment", "Please enter comment text", comment.GetContent(), wx.OK|wx.CANCEL|wx.TE_MULTILINE) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2252 |
else: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2253 |
dialog = wx.TextEntryDialog(self.ParentWindow, "Edit comment", "Please enter comment text", comment.GetContent(), wx.OK|wx.CANCEL) |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
2254 |
if dialog.ShowModal() == wx.ID_OK: |
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
2255 |
value = dialog.GetValue() |
154 | 2256 |
rect = comment.GetRedrawRect(1, 1) |
90
2245e8776086
Adding support support for using PLCOpenEditor with Beremiz
lbessard
parents:
80
diff
changeset
|
2257 |
comment.SetContent(value) |
145 | 2258 |
comment.SetSize(*self.GetScaledSize(*comment.GetSize())) |
154 | 2259 |
rect = rect.Union(comment.GetRedrawRect()) |
2260 |
self.RefreshCommentModel(comment) |
|
2261 |
self.RefreshBuffer() |
|
2262 |
self.RefreshScrollBars() |
|
249 | 2263 |
self.RefreshVisibleElements() |
154 | 2264 |
comment.Refresh(rect) |
64
dd6f693e46a1
Cleaning code for using only wxPython 2.6 class naming
lbessard
parents:
61
diff
changeset
|
2265 |
dialog.Destroy() |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2266 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2267 |
#------------------------------------------------------------------------------- |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2268 |
# Model update functions |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2269 |
#------------------------------------------------------------------------------- |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2270 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2271 |
def RefreshBlockModel(self, block): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2272 |
blockid = block.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2273 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2274 |
infos["type"] = block.GetType() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2275 |
infos["name"] = block.GetName() |
145 | 2276 |
if self.CurrentLanguage == "FBD": |
2277 |
infos["executionOrder"] = block.GetExecutionOrder() |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2278 |
infos["x"], infos["y"] = block.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2279 |
infos["width"], infos["height"] = block.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2280 |
infos["connectors"] = block.GetConnectors() |
121 | 2281 |
self.Controler.SetEditedElementBlockInfos(self.TagName, blockid, infos) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2282 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2283 |
def RefreshVariableModel(self, variable): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2284 |
variableid = variable.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2285 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2286 |
infos["name"] = variable.GetName() |
145 | 2287 |
if self.CurrentLanguage == "FBD": |
2288 |
infos["executionOrder"] = variable.GetExecutionOrder() |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2289 |
infos["x"], infos["y"] = variable.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2290 |
infos["width"], infos["height"] = variable.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2291 |
infos["connectors"] = variable.GetConnectors() |
121 | 2292 |
self.Controler.SetEditedElementVariableInfos(self.TagName, variableid, infos) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2293 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2294 |
def RefreshConnectionModel(self, connection): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2295 |
connectionid = connection.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2296 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2297 |
infos["name"] = connection.GetName() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2298 |
infos["x"], infos["y"] = connection.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2299 |
infos["width"], infos["height"] = connection.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2300 |
infos["connector"] = connection.GetConnector() |
121 | 2301 |
self.Controler.SetEditedElementConnectionInfos(self.TagName, connectionid, infos) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2302 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2303 |
def RefreshCommentModel(self, comment): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2304 |
commentid = comment.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2305 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2306 |
infos["content"] = comment.GetContent() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2307 |
infos["x"], infos["y"] = comment.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2308 |
infos["width"], infos["height"] = comment.GetSize() |
121 | 2309 |
self.Controler.SetEditedElementCommentInfos(self.TagName, commentid, infos) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2310 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2311 |
def RefreshPowerRailModel(self, powerrail): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2312 |
powerrailid = powerrail.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2313 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2314 |
infos["x"], infos["y"] = powerrail.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2315 |
infos["width"], infos["height"] = powerrail.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2316 |
infos["connectors"] = powerrail.GetConnectors() |
121 | 2317 |
self.Controler.SetEditedElementPowerRailInfos(self.TagName, powerrailid, infos) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2318 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2319 |
def RefreshContactModel(self, contact): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2320 |
contactid = contact.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2321 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2322 |
infos["name"] = contact.GetName() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2323 |
infos["type"] = contact.GetType() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2324 |
infos["x"], infos["y"] = contact.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2325 |
infos["width"], infos["height"] = contact.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2326 |
infos["connectors"] = contact.GetConnectors() |
121 | 2327 |
self.Controler.SetEditedElementContactInfos(self.TagName, contactid, infos) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2328 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2329 |
def RefreshCoilModel(self, coil): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2330 |
coilid = coil.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2331 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2332 |
infos["name"] = coil.GetName() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2333 |
infos["type"] = coil.GetType() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2334 |
infos["x"], infos["y"] = coil.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2335 |
infos["width"], infos["height"] = coil.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2336 |
infos["connectors"] = coil.GetConnectors() |
121 | 2337 |
self.Controler.SetEditedElementCoilInfos(self.TagName, coilid, infos) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2338 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2339 |
def RefreshStepModel(self, step): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2340 |
stepid = step.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2341 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2342 |
infos["name"] = step.GetName() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2343 |
infos["initial"] = step.GetInitial() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2344 |
infos["x"], infos["y"] = step.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2345 |
infos["width"], infos["height"] = step.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2346 |
infos["connectors"] = step.GetConnectors() |
121 | 2347 |
self.Controler.SetEditedElementStepInfos(self.TagName, stepid, infos) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2348 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2349 |
def RefreshTransitionModel(self, transition): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2350 |
transitionid = transition.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2351 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2352 |
infos["type"] = transition.GetType() |
80 | 2353 |
infos["priority"] = transition.GetPriority() |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2354 |
infos["condition"] = transition.GetCondition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2355 |
infos["x"], infos["y"] = transition.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2356 |
infos["width"], infos["height"] = transition.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2357 |
infos["connectors"] = transition.GetConnectors() |
121 | 2358 |
self.Controler.SetEditedElementTransitionInfos(self.TagName, transitionid, infos) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2359 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2360 |
def RefreshDivergenceModel(self, divergence): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2361 |
divergenceid = divergence.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2362 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2363 |
infos["x"], infos["y"] = divergence.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2364 |
infos["width"], infos["height"] = divergence.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2365 |
infos["connectors"] = divergence.GetConnectors() |
121 | 2366 |
self.Controler.SetEditedElementDivergenceInfos(self.TagName, divergenceid, infos) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2367 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2368 |
def RefreshJumpModel(self, jump): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2369 |
jumpid = jump.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2370 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2371 |
infos["target"] = jump.GetTarget() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2372 |
infos["x"], infos["y"] = jump.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2373 |
infos["width"], infos["height"] = jump.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2374 |
infos["connector"] = jump.GetConnector() |
121 | 2375 |
self.Controler.SetEditedElementJumpInfos(self.TagName, jumpid, infos) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2376 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2377 |
def RefreshActionBlockModel(self, actionblock): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2378 |
actionblockid = actionblock.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2379 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2380 |
infos["actions"] = actionblock.GetActions() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2381 |
infos["x"], infos["y"] = actionblock.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2382 |
infos["width"], infos["height"] = actionblock.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2383 |
infos["connector"] = actionblock.GetConnector() |
121 | 2384 |
self.Controler.SetEditedElementActionBlockInfos(self.TagName, actionblockid, infos) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2385 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2386 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2387 |
#------------------------------------------------------------------------------- |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2388 |
# Model delete functions |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2389 |
#------------------------------------------------------------------------------- |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2390 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2391 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2392 |
def DeleteBlock(self, block): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2393 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2394 |
for output in block.GetConnectors()["outputs"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2395 |
for element in output.GetConnectedBlocks(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2396 |
if element not in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2397 |
elements.append(element) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2398 |
block.Clean() |
42 | 2399 |
self.RemoveBlock(block) |
121 | 2400 |
self.Controler.RemoveEditedElementInstance(self.TagName, block.GetId()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2401 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2402 |
element.RefreshModel() |
144 | 2403 |
wx.CallAfter(self.ParentWindow.RefreshVariablePanel, self.TagName) |
239
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
2404 |
wx.CallAfter(self.ParentWindow.RefreshInstancesTree) |
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
2405 |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2406 |
def DeleteVariable(self, variable): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2407 |
connectors = variable.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2408 |
if connectors["output"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2409 |
elements = connectors["output"].GetConnectedBlocks() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2410 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2411 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2412 |
variable.Clean() |
42 | 2413 |
self.RemoveBlock(variable) |
121 | 2414 |
self.Controler.RemoveEditedElementInstance(self.TagName, variable.GetId()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2415 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2416 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2417 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2418 |
def DeleteConnection(self, connection): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2419 |
if connection.GetType() == CONTINUATION: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2420 |
elements = connection.GetConnector().GetConnectedBlocks() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2421 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2422 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2423 |
connection.Clean() |
42 | 2424 |
self.RemoveBlock(connection) |
121 | 2425 |
self.Controler.RemoveEditedElementInstance(self.TagName, connection.GetId()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2426 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2427 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2428 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2429 |
def DeleteComment(self, comment): |
42 | 2430 |
self.RemoveComment(comment) |
121 | 2431 |
self.Controler.RemoveEditedElementInstance(self.TagName, comment.GetId()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2432 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2433 |
def DeleteWire(self, wire): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2434 |
if wire in self.Wires: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2435 |
connected = wire.GetConnected() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2436 |
wire.Clean() |
42 | 2437 |
self.RemoveWire(wire) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2438 |
for connector in connected: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2439 |
connector.RefreshParentBlock() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2440 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2441 |
def DeleteContact(self, contact): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2442 |
connectors = contact.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2443 |
elements = connectors["output"].GetConnectedBlocks() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2444 |
contact.Clean() |
42 | 2445 |
self.RemoveBlock(contact) |
121 | 2446 |
self.Controler.RemoveEditedElementInstance(self.TagName, contact.GetId()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2447 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2448 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2449 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2450 |
def DeleteCoil(self, coil): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2451 |
connectors = coil.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2452 |
elements = connectors["output"].GetConnectedBlocks() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2453 |
coil.Clean() |
42 | 2454 |
self.RemoveBlock(coil) |
121 | 2455 |
self.Controler.RemoveEditedElementInstance(self.TagName, coil.GetId()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2456 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2457 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2458 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2459 |
def DeletePowerRail(self, powerrail): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2460 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2461 |
if powerrail.GetType() == LEFTRAIL: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2462 |
for connector in powerrail.GetConnectors(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2463 |
for element in connector.GetConnectedBlocks(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2464 |
if element not in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2465 |
elements.append(element) |
108 | 2466 |
powerrail.Clean() |
2467 |
self.RemoveBlock(powerrail) |
|
121 | 2468 |
self.Controler.RemoveEditedElementInstance(self.TagName, powerrail.GetId()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2469 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2470 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2471 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2472 |
def DeleteStep(self, step): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2473 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2474 |
connectors = step.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2475 |
if connectors["output"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2476 |
for element in connectors["output"].GetConnectedBlocks(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2477 |
if element not in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2478 |
elements.append(element) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2479 |
if connectors["action"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2480 |
for element in connectors["action"].GetConnectedBlocks(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2481 |
if element not in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2482 |
elements.append(element) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2483 |
step.Clean() |
42 | 2484 |
self.RemoveBlock(step) |
121 | 2485 |
self.Controler.RemoveEditedElementInstance(self.TagName, step.GetId()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2486 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2487 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2488 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2489 |
def DeleteTransition(self, transition): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2490 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2491 |
connectors = transition.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2492 |
if connectors["output"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2493 |
for element in connectors["output"].GetConnectedBlocks(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2494 |
if element not in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2495 |
elements.append(element) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2496 |
transition.Clean() |
42 | 2497 |
self.RemoveBlock(transition) |
121 | 2498 |
self.Controler.RemoveEditedElementInstance(self.TagName, transition.GetId()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2499 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2500 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2501 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2502 |
def DeleteDivergence(self, divergence): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2503 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2504 |
connectors = divergence.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2505 |
for output in connectors["outputs"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2506 |
for element in output.GetConnectedBlocks(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2507 |
if element not in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2508 |
elements.append(element) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2509 |
divergence.Clean() |
42 | 2510 |
self.RemoveBlock(divergence) |
121 | 2511 |
self.Controler.RemoveEditedElementInstance(self.TagName, divergence.GetId()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2512 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2513 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2514 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2515 |
def DeleteJump(self, jump): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2516 |
jump.Clean() |
42 | 2517 |
self.RemoveBlock(jump) |
121 | 2518 |
self.Controler.RemoveEditedElementInstance(self.TagName, jump.GetId()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2519 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2520 |
def DeleteActionBlock(self, actionblock): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2521 |
actionblock.Clean() |
42 | 2522 |
self.RemoveBlock(actionblock) |
121 | 2523 |
self.Controler.RemoveEditedElementInstance(self.TagName, actionblock.GetId()) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
2524 |
|
27 | 2525 |
|
0 | 2526 |
#------------------------------------------------------------------------------- |
2527 |
# Editing functions |
|
2528 |
#------------------------------------------------------------------------------- |
|
2529 |
||
2530 |
def Cut(self): |
|
283 | 2531 |
if not self.Debug and (self.IsBlock(self.SelectedElement) or self.IsComment(self.SelectedElement) or isinstance(self.SelectedElement, Graphic_Group)): |
162 | 2532 |
self.ParentWindow.SetCopyBuffer(self.SelectedElement.Clone(self)) |
144 | 2533 |
rect = self.SelectedElement.GetRedrawRect(1, 1) |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2534 |
self.SelectedElement.Delete() |
144 | 2535 |
self.SelectedElement = None |
2536 |
self.RefreshBuffer() |
|
2537 |
self.RefreshScrollBars() |
|
239
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
2538 |
self.ParentWindow.RefreshVariablePanel(self.TagName) |
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
2539 |
self.ParentWindow.RefreshInstancesTree() |
155 | 2540 |
self.RefreshRect(self.GetScrolledRect(rect), False) |
0 | 2541 |
|
2542 |
def Copy(self): |
|
283 | 2543 |
if not self.Debug and (self.IsBlock(self.SelectedElement) or self.IsComment(self.SelectedElement) or isinstance(self.SelectedElement, Graphic_Group)): |
162 | 2544 |
self.ParentWindow.SetCopyBuffer(self.SelectedElement.Clone(self)) |
144 | 2545 |
|
0 | 2546 |
def Paste(self): |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2547 |
element = self.ParentWindow.GetCopyBuffer() |
283 | 2548 |
if not self.Debug and element is not None and self.CanAddElement(element): |
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2549 |
block = self.CopyBlock(element, wx.Point(*self.CalcUnscrolledPosition(30, 30))) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2550 |
if self.SelectedElement is not None: |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2551 |
self.SelectedElement.SetSelected(False) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2552 |
self.SelectedElement = block |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2553 |
self.SelectedElement.SetSelected(True) |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2554 |
self.RefreshBuffer() |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2555 |
self.RefreshScrollBars() |
249 | 2556 |
self.RefreshVisibleElements() |
144 | 2557 |
self.ParentWindow.RefreshVariablePanel(self.TagName) |
239
d12779e971bd
Adding support for function and functionBlock (standard or user) library
lbessard
parents:
235
diff
changeset
|
2558 |
self.ParentWindow.RefreshInstancesTree() |
283 | 2559 |
else: |
2560 |
message = wx.MessageDialog(self, "You can't paste the element in buffer here!", "Error", wx.OK|wx.ICON_ERROR) |
|
2561 |
message.ShowModal() |
|
2562 |
message.Destroy() |
|
2563 |
||
2564 |
def CanAddElement(self, block): |
|
2565 |
if isinstance(block, Graphic_Group): |
|
2566 |
return block.CanAddBlocks(self) |
|
2567 |
elif self.CurrentLanguage == "SFC": |
|
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2568 |
return True |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2569 |
elif self.CurrentLanguage == "LD" and not isinstance(block, (SFC_Step, SFC_Transition, SFC_Divergence, SFC_Jump, SFC_ActionBlock)): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2570 |
return True |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2571 |
elif self.CurrentLanguage == "FBD" and isinstance(block, (FBD_Block, FBD_Variable, FBD_Connector, Comment)): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2572 |
return True |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2573 |
return False |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2574 |
|
283 | 2575 |
def GenerateNewName(self, element): |
2576 |
if isinstance(element, FBD_Block): |
|
2577 |
names = [varname.upper() for varname in self.Controler.GetEditedElementVariables(self.TagName, self.Debug)] |
|
2578 |
format = "Block%d" |
|
2579 |
elif isinstance(element, SFC_Step): |
|
2580 |
names = [block.GetName().upper() for block in self.Blocks if isinstance(block, SFC_Step)] |
|
2581 |
format = "Step%d" |
|
2582 |
i = 1 |
|
2583 |
while (format%i).upper() in names: |
|
2584 |
i += 1 |
|
2585 |
return format%i |
|
2586 |
||
2587 |
def IsNamedElement(self, element): |
|
2588 |
return isinstance(element, FBD_Block) and element.GetName() != "" or isinstance(element, SFC_Step) |
|
2589 |
||
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2590 |
def CopyBlock(self, element, pos): |
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2591 |
id = self.GetNewId() |
283 | 2592 |
if isinstance(element, Graphic_Group): |
2593 |
block = element.Clone(self, pos=pos) |
|
144 | 2594 |
else: |
283 | 2595 |
if self.IsNamedElement(element): |
2596 |
name = self.GenerateNewName(element) |
|
2597 |
block = element.Clone(self, id, name, pos) |
|
2598 |
else: |
|
2599 |
name = None |
|
2600 |
block = element.Clone(self, id, pos=pos) |
|
2601 |
self.AddBlockInModel(block) |
|
2602 |
return block |
|
2603 |
||
2604 |
def AddBlockInModel(self, block): |
|
114
06454545e5d0
Adding support for block copy and for wxpython 2.4
lbessard
parents:
111
diff
changeset
|
2605 |
if isinstance(block, Comment): |
178 | 2606 |
self.AddComment(block) |
283 | 2607 |
self.Controler.AddEditedElementComment(self.TagName, block.GetId()) |
144 | 2608 |
self.RefreshCommentModel(block) |
178 | 2609 |
else: |
2610 |
self.AddBlock(block) |
|
2611 |
if isinstance(block, FBD_Block): |
|
283 | 2612 |
self.Controler.AddEditedElementBlock(self.TagName, block.GetId(), block.GetType(), block.GetName()) |
178 | 2613 |
self.RefreshBlockModel(block) |
2614 |
elif isinstance(block, FBD_Variable): |
|
283 | 2615 |
self.Controler.AddEditedElementVariable(self.TagName, block.GetId(), block.GetType()) |
178 | 2616 |
self.RefreshVariableModel(block) |
2617 |
elif isinstance(block, FBD_Connector): |
|
283 | 2618 |
self.Controler.AddEditedElementConnection(self.TagName, block.GetId(), block.GetType()) |
178 | 2619 |
self.RefreshConnectionModel(block) |
2620 |
elif isinstance(block, LD_Contact): |
|
283 | 2621 |
self.Controler.AddEditedElementContact(self.TagName, block.GetId()) |
178 | 2622 |
self.RefreshContactModel(block) |
2623 |
elif isinstance(block, LD_Coil): |
|
283 | 2624 |
self.Controler.AddEditedElementCoil(self.TagName, block.GetId()) |
178 | 2625 |
self.RefreshCoilModel(block) |
2626 |
elif isinstance(block, LD_PowerRail): |
|
283 | 2627 |
self.Controler.AddEditedElementPowerRail(self.TagName, block.GetId(), block.GetType()) |
178 | 2628 |
self.RefreshPowerRailModel(block) |
2629 |
elif isinstance(block, SFC_Step): |
|
283 | 2630 |
self.Controler.AddEditedElementStep(self.TagName, block.GetId()) |
178 | 2631 |
self.RefreshStepModel(block) |
2632 |
elif isinstance(block, SFC_Transition): |
|
283 | 2633 |
self.Controler.AddEditedElementTransition(self.TagName, block.GetId()) |
178 | 2634 |
self.RefreshTransitionModel(block) |
2635 |
elif isinstance(block, SFC_Divergence): |
|
283 | 2636 |
self.Controler.AddEditedElementDivergence(self.TagName, block.GetId(), block.GetType()) |
202 | 2637 |
self.RefreshDivergenceModel(block) |
178 | 2638 |
elif isinstance(block, SFC_Jump): |
283 | 2639 |
self.Controler.AddEditedElementJump(self.TagName, block.GetId()) |
178 | 2640 |
self.RefreshJumpModel(block) |
2641 |
elif isinstance(block, SFC_ActionBlock): |
|
283 | 2642 |
self.Controler.AddEditedElementActionBlock(self.TagName, block.GetId()) |
178 | 2643 |
self.RefreshActionBlockModel(block) |
231
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2644 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2645 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2646 |
#------------------------------------------------------------------------------- |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2647 |
# Errors showing functions |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2648 |
#------------------------------------------------------------------------------- |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2649 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2650 |
def ClearErrors(self): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2651 |
self.Errors = [] |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2652 |
self.RefreshView() |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2653 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2654 |
def AddShownError(self, infos, start, end): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2655 |
self.Errors.append((infos, start, end)) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2656 |
|
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2657 |
def ShowErrors(self): |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2658 |
for infos, start, end in self.Errors: |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2659 |
if infos[0] in ["io_variable", "block", "coil", "contact", "transition", "step", "action_block"]: |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2660 |
block = self.FindElementById(infos[1]) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2661 |
if block is not None: |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2662 |
block.AddError(infos[2:], start, end) |
fc2d6cbb8b39
Adding support for highlighing compiling errors from matiec
lbessard
parents:
224
diff
changeset
|
2663 |
|
0 | 2664 |
#------------------------------------------------------------------------------- |
2665 |
# Drawing functions |
|
2666 |
#------------------------------------------------------------------------------- |
|
2667 |
||
249 | 2668 |
def OnScrollWindow(self, event): |
2669 |
if event.GetOrientation() == wx.HORIZONTAL: |
|
2670 |
self.RefreshVisibleElements(xp = event.GetPosition()) |
|
2671 |
else: |
|
2672 |
self.RefreshVisibleElements(yp = event.GetPosition()) |
|
2673 |
event.Skip() |
|
2674 |
||
319 | 2675 |
def OnScrollStop(self, event): |
2676 |
self.RefreshScrollBars() |
|
2677 |
event.Skip() |
|
2678 |
||
253 | 2679 |
def OnMouseWheelWindow(self, event): |
319 | 2680 |
if self.StartMousePos is None or self.StartScreenPos is None: |
323 | 2681 |
rotation = event.GetWheelRotation() / event.GetWheelDelta() |
2682 |
if event.ShiftDown(): |
|
2683 |
x, y = self.GetViewStart() |
|
2684 |
xp = max(0, min(x - rotation * 3, self.GetVirtualSize()[0] / self.GetScrollPixelsPerUnit()[0])) |
|
2685 |
self.RefreshVisibleElements(xp = xp) |
|
2686 |
self.Scroll(xp, y) |
|
2687 |
elif event.ControlDown(): |
|
2688 |
dc = self.GetLogicalDC() |
|
2689 |
pos = event.GetLogicalPosition(dc) |
|
2690 |
mouse_pos = event.GetPosition() |
|
2691 |
factor = 0.75 ** rotation |
|
2692 |
self.SetScale(self.ViewScale[0] * factor, self.ViewScale[1] * factor) |
|
2693 |
self.Scroll(round(pos.x * self.ViewScale[0] - mouse_pos.x) / SCROLLBAR_UNIT, |
|
2694 |
round(pos.y * self.ViewScale[1] - mouse_pos.y) / SCROLLBAR_UNIT) |
|
2695 |
self.RefreshScrollBars() |
|
2696 |
self.RefreshVisibleElements() |
|
2697 |
self.Refresh() |
|
2698 |
else: |
|
2699 |
x, y = self.GetViewStart() |
|
2700 |
yp = max(0, min(y - rotation * 3, self.GetVirtualSize()[1] / self.GetScrollPixelsPerUnit()[1])) |
|
2701 |
self.RefreshVisibleElements(yp = yp) |
|
2702 |
self.Scroll(x, yp) |
|
253 | 2703 |
|
27 | 2704 |
def OnMoveWindow(self, event): |
292 | 2705 |
if not USE_AUI: |
2706 |
self.GetBestSize() |
|
42 | 2707 |
self.RefreshScrollBars() |
249 | 2708 |
self.RefreshVisibleElements() |
27 | 2709 |
event.Skip() |
2710 |
||
213 | 2711 |
def DoDrawing(self, dc, printing = False): |
2712 |
if printing: |
|
2713 |
if getattr(dc, "printing", False): |
|
2714 |
font = wx.Font(self.GetFont().GetPointSize(), wx.MODERN, wx.NORMAL, wx.NORMAL) |
|
2715 |
dc.SetFont(font) |
|
2716 |
else: |
|
2717 |
dc.SetFont(self.GetFont()) |
|
2718 |
else: |
|
2719 |
dc.SetBackground(wx.Brush(self.GetBackgroundColour())) |
|
2720 |
dc.Clear() |
|
2721 |
dc.BeginDrawing() |
|
2722 |
if self.Scaling is not None and self.DrawGrid and not printing: |
|
145 | 2723 |
dc.SetPen(wx.TRANSPARENT_PEN) |
2724 |
dc.SetBrush(self.GridBrush) |
|
213 | 2725 |
xstart, ystart = self.GetViewStart() |
2726 |
window_size = self.GetClientSize() |
|
145 | 2727 |
width, height = self.GetVirtualSize() |
323 | 2728 |
width = int(max(width, xstart * SCROLLBAR_UNIT + window_size[0]) / self.ViewScale[0]) |
2729 |
height = int(max(height, ystart * SCROLLBAR_UNIT + window_size[1]) / self.ViewScale[1]) |
|
145 | 2730 |
dc.DrawRectangle(0, 0, width, height) |
213 | 2731 |
if self.PageSize is not None and not printing: |
2732 |
dc.SetPen(self.PagePen) |
|
2733 |
xstart, ystart = self.GetViewStart() |
|
2734 |
window_size = self.GetClientSize() |
|
2735 |
for x in xrange(self.PageSize[0] - (xstart * SCROLLBAR_UNIT) % self.PageSize[0], window_size[0], self.PageSize[0]): |
|
2736 |
dc.DrawLine(xstart * SCROLLBAR_UNIT + x + 1, ystart * SCROLLBAR_UNIT, |
|
2737 |
xstart * SCROLLBAR_UNIT + x + 1, ystart * SCROLLBAR_UNIT + window_size[1]) |
|
2738 |
for y in xrange(self.PageSize[1] - (ystart * SCROLLBAR_UNIT) % self.PageSize[1], window_size[1], self.PageSize[1]): |
|
2739 |
dc.DrawLine(xstart * SCROLLBAR_UNIT, ystart * SCROLLBAR_UNIT + y + 1, |
|
2740 |
xstart * SCROLLBAR_UNIT + window_size[0], ystart * SCROLLBAR_UNIT + y + 1) |
|
140
06d28f03f6f4
Adding highlighting on group or element when mouse is over
lbessard
parents:
138
diff
changeset
|
2741 |
|
06d28f03f6f4
Adding highlighting on group or element when mouse is over
lbessard
parents:
138
diff
changeset
|
2742 |
# Draw all elements |
42 | 2743 |
for comment in self.Comments: |
249 | 2744 |
if comment != self.SelectedElement and (comment.IsVisible() or printing): |
42 | 2745 |
comment.Draw(dc) |
0 | 2746 |
for wire in self.Wires: |
249 | 2747 |
if wire != self.SelectedElement and (wire.IsVisible() or printing): |
2748 |
if not self.Debug or wire.GetValue() != True: |
|
2749 |
wire.Draw(dc) |
|
2750 |
if self.Debug: |
|
2751 |
for wire in self.Wires: |
|
2752 |
if wire != self.SelectedElement and (wire.IsVisible() or printing) and wire.GetValue() == True: |
|
2753 |
wire.Draw(dc) |
|
42 | 2754 |
for block in self.Blocks: |
249 | 2755 |
if block != self.SelectedElement and (block.IsVisible() or printing): |
42 | 2756 |
block.Draw(dc) |
144 | 2757 |
|
249 | 2758 |
if self.SelectedElement is not None and (self.SelectedElement.IsVisible() or printing): |
2759 |
self.SelectedElement.Draw(dc) |
|
213 | 2760 |
|
2761 |
if not printing: |
|
2762 |
if self.rubberBand.IsShown(): |
|
2763 |
self.rubberBand.Draw(dc) |
|
2764 |
dc.EndDrawing() |
|
2765 |
||
2766 |
def OnPaint(self, event): |
|
2767 |
self.DoDrawing(self.GetLogicalDC(True)) |
|
2768 |
event.Skip() |
|
2769 |
||
2770 |