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