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