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