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