author | lbessard |
Thu, 19 Jul 2007 15:04:41 +0200 | |
changeset 46 | 4379e98a30aa |
parent 45 | 42637f721b5b |
child 47 | 2b2f8d88e6d3 |
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 |
# |
|
7 |
#Copyright (C): Edouard TISSERANT and Laurent BESSARD |
|
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 |
|
19 |
#Lesser General Public License for more details. |
|
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 |
from wxPython.wx import * |
|
26 |
import wx |
|
27 |
||
28 |
from plcopen.structures import * |
|
27 | 29 |
|
30 |
from Dialogs import * |
|
31 |
||
32 |
SCROLLBAR_UNIT = 10 |
|
33 |
WINDOW_BORDER = 10 |
|
34 |
SCROLL_ZONE = 10 |
|
0 | 35 |
|
36 |
#------------------------------------------------------------------------------- |
|
37 |
# Graphic elements Viewer base class |
|
38 |
#------------------------------------------------------------------------------- |
|
39 |
||
40 |
# ID Constants for menu items |
|
41 |
[wxID_FBDVIEWERCONTEXTUALMENUITEMS0, wxID_FBDVIEWERCONTEXTUALMENUITEMS1, |
|
42 |
wxID_FBDVIEWERCONTEXTUALMENUITEMS2, wxID_FBDVIEWERCONTEXTUALMENUITEMS3, |
|
43 |
wxID_FBDVIEWERCONTEXTUALMENUITEMS5, wxID_FBDVIEWERCONTEXTUALMENUITEMS6, |
|
44 |
wxID_FBDVIEWERCONTEXTUALMENUITEMS8, wxID_FBDVIEWERCONTEXTUALMENUITEMS9, |
|
45 |
wxID_FBDVIEWERCONTEXTUALMENUITEMS11, |
|
46 |
] = [wx.NewId() for _init_coll_ContextualMenu_Items in range(9)] |
|
47 |
||
48 |
||
49 |
""" |
|
50 |
Class that implements a Viewer based on a wxScrolledWindow for drawing and |
|
51 |
manipulating graphic elements |
|
52 |
""" |
|
53 |
||
54 |
class Viewer(wx.ScrolledWindow): |
|
55 |
||
56 |
# Create Contextual Menu items |
|
57 |
def _init_coll_ContextualMenu_Items(self, parent): |
|
58 |
# Create menu items |
|
59 |
parent.Append(help='', id=wxID_FBDVIEWERCONTEXTUALMENUITEMS0, |
|
60 |
kind=wx.ITEM_RADIO, text=u'No Modifier') |
|
61 |
parent.Append(help='', id=wxID_FBDVIEWERCONTEXTUALMENUITEMS1, |
|
62 |
kind=wx.ITEM_RADIO, text=u'Negated') |
|
63 |
parent.Append(help='', id=wxID_FBDVIEWERCONTEXTUALMENUITEMS2, |
|
64 |
kind=wx.ITEM_RADIO, text=u'Rising Edge') |
|
65 |
parent.Append(help='', id=wxID_FBDVIEWERCONTEXTUALMENUITEMS3, |
|
66 |
kind=wx.ITEM_RADIO, text=u'Falling Edge') |
|
67 |
parent.AppendSeparator() |
|
68 |
parent.Append(help='', id=wxID_FBDVIEWERCONTEXTUALMENUITEMS5, |
|
69 |
kind=wx.ITEM_NORMAL, text=u'Add Wire Segment') |
|
70 |
parent.Append(help='', id=wxID_FBDVIEWERCONTEXTUALMENUITEMS6, |
|
71 |
kind=wx.ITEM_NORMAL, text=u'Delete Wire Segment') |
|
72 |
parent.AppendSeparator() |
|
73 |
parent.Append(help='', id=wxID_FBDVIEWERCONTEXTUALMENUITEMS8, |
|
74 |
kind=wx.ITEM_NORMAL, text=u'Add Divergence Branch') |
|
75 |
parent.Append(help='', id=wxID_FBDVIEWERCONTEXTUALMENUITEMS9, |
|
76 |
kind=wx.ITEM_NORMAL, text=u'Delete Divergence Branch') |
|
77 |
parent.AppendSeparator() |
|
78 |
parent.Append(help='', id=wxID_FBDVIEWERCONTEXTUALMENUITEMS11, |
|
79 |
kind=wx.ITEM_NORMAL, text=u'Delete') |
|
80 |
# Link menu event to corresponding called functions |
|
81 |
self.Bind(wx.EVT_MENU, self.OnNoModifierMenu, |
|
82 |
id=wxID_FBDVIEWERCONTEXTUALMENUITEMS0) |
|
83 |
self.Bind(wx.EVT_MENU, self.OnNegatedMenu, |
|
84 |
id=wxID_FBDVIEWERCONTEXTUALMENUITEMS1) |
|
85 |
self.Bind(wx.EVT_MENU, self.OnRisingEdgeMenu, |
|
86 |
id=wxID_FBDVIEWERCONTEXTUALMENUITEMS2) |
|
87 |
self.Bind(wx.EVT_MENU, self.OnFallingEdgeMenu, |
|
88 |
id=wxID_FBDVIEWERCONTEXTUALMENUITEMS3) |
|
89 |
self.Bind(wx.EVT_MENU, self.OnAddSegmentMenu, |
|
90 |
id=wxID_FBDVIEWERCONTEXTUALMENUITEMS5) |
|
91 |
self.Bind(wx.EVT_MENU, self.OnDeleteSegmentMenu, |
|
92 |
id=wxID_FBDVIEWERCONTEXTUALMENUITEMS6) |
|
93 |
self.Bind(wx.EVT_MENU, self.OnAddBranchMenu, |
|
94 |
id=wxID_FBDVIEWERCONTEXTUALMENUITEMS8) |
|
95 |
self.Bind(wx.EVT_MENU, self.OnDeleteBranchMenu, |
|
96 |
id=wxID_FBDVIEWERCONTEXTUALMENUITEMS9) |
|
97 |
self.Bind(wx.EVT_MENU, self.OnDeleteMenu, |
|
98 |
id=wxID_FBDVIEWERCONTEXTUALMENUITEMS11) |
|
99 |
||
100 |
# Create and initialize Contextual Menu |
|
101 |
def _init_menus(self): |
|
102 |
self.ContextualMenu = wx.Menu(title='') |
|
103 |
||
104 |
self._init_coll_ContextualMenu_Items(self.ContextualMenu) |
|
105 |
||
106 |
# Create a new Viewer |
|
107 |
def __init__(self, parent, window, controler): |
|
27 | 108 |
wx.ScrolledWindow.__init__(self, parent, style=wx.SUNKEN_BORDER | wx.HSCROLL | wx.VSCROLL) |
0 | 109 |
self._init_menus() |
110 |
# Adding a rubberband to Viewer |
|
111 |
self.rubberBand = RubberBand(drawingSurface=self) |
|
112 |
self.SetBackgroundColour(wxColour(255,255,255)) |
|
113 |
self.ResetView() |
|
114 |
self.Scaling = None |
|
115 |
#self.Scaling = (8, 8) |
|
116 |
self.DrawGrid = True |
|
117 |
self.current_id = 0 |
|
118 |
||
42 | 119 |
# Initialize Block, Wire and Comment numbers |
120 |
self.block_id = self.wire_id = self.comment_id = 0 |
|
121 |
||
0 | 122 |
# Initialize Viewer mode to Selection mode |
123 |
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
|
124 |
self.SavedMode = False |
0 | 125 |
|
126 |
self.Parent = window |
|
127 |
self.Controler = controler |
|
128 |
||
129 |
# Link Viewer event to corresponding methods |
|
130 |
EVT_PAINT(self, self.OnPaint) |
|
131 |
EVT_LEFT_DOWN(self, self.OnViewerLeftDown) |
|
132 |
EVT_LEFT_UP(self, self.OnViewerLeftUp) |
|
133 |
EVT_LEFT_DCLICK(self, self.OnViewerLeftDClick) |
|
134 |
EVT_RIGHT_UP(self, self.OnViewerRightUp) |
|
135 |
EVT_MOTION(self, self.OnViewerMotion) |
|
136 |
EVT_CHAR(self, self.OnChar) |
|
27 | 137 |
EVT_SCROLLWIN(self, self.OnMoveWindow) |
138 |
EVT_SIZE(self, self.OnMoveWindow) |
|
0 | 139 |
|
140 |
# Returns a new id |
|
141 |
def GetNewId(self): |
|
142 |
self.current_id += 1 |
|
143 |
return self.current_id |
|
144 |
||
145 |
# Destructor |
|
146 |
def __del__(self): |
|
147 |
self.ResetView() |
|
148 |
||
27 | 149 |
def GetLogicalDC(self): |
150 |
dc = wxClientDC(self) |
|
151 |
self.DoPrepareDC(dc) |
|
152 |
return dc |
|
153 |
||
0 | 154 |
#------------------------------------------------------------------------------- |
42 | 155 |
# Element management functions |
156 |
#------------------------------------------------------------------------------- |
|
157 |
||
158 |
def AddBlock(self, block): |
|
159 |
self.block_id += 1 |
|
160 |
self.Blocks[block] = self.block_id |
|
161 |
||
162 |
def AddWire(self, wire): |
|
163 |
self.wire_id += 1 |
|
164 |
self.Wires[wire] = self.wire_id |
|
165 |
||
166 |
def AddComment(self, comment): |
|
167 |
self.comment_id += 1 |
|
168 |
self.Comments[comment] = self.comment_id |
|
169 |
||
170 |
def IsBlock(self, block): |
|
171 |
return self.Blocks.get(block, False) |
|
172 |
||
173 |
def IsWire(self, wire): |
|
174 |
return self.Wires.get(wire, False) |
|
175 |
||
176 |
def IsComment(self, comment): |
|
177 |
return self.Comments.get(comment, False) |
|
178 |
||
179 |
def RemoveBlock(self, block): |
|
180 |
self.Blocks.pop(block) |
|
181 |
||
182 |
def RemoveWire(self, wire): |
|
183 |
self.Wires.pop(wire) |
|
184 |
||
185 |
def RemoveComment(self, comment): |
|
186 |
self.Comments.pop(comment) |
|
187 |
||
188 |
def GetElements(self, sort_blocks=False, sort_wires=False, sort_comments=False): |
|
189 |
blocks = self.Blocks.keys() |
|
190 |
wires = self.Wires.keys() |
|
191 |
comments = self.Comments.keys() |
|
192 |
if sort_blocks: |
|
193 |
blocks.sort(lambda x,y:self.Blocks[x].__cmp__(self.Blocks[y])) |
|
194 |
if sort_wires: |
|
195 |
wires.sort(lambda x,y:self.Wires[x].__cmp__(self.Wires[y])) |
|
196 |
if sort_comments: |
|
197 |
comments.sort(lambda x,y:self.Comments[x].__cmp__(self.Comments[y])) |
|
198 |
return blocks + wires + comments |
|
199 |
||
200 |
#------------------------------------------------------------------------------- |
|
0 | 201 |
# Reset functions |
202 |
#------------------------------------------------------------------------------- |
|
203 |
||
204 |
# Resets Viewer lists |
|
205 |
def ResetView(self): |
|
42 | 206 |
self.Blocks = {} |
207 |
self.Wires = {} |
|
208 |
self.Comments = {} |
|
0 | 209 |
self.SelectedElement = None |
210 |
||
211 |
# Changes Viewer mode |
|
212 |
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
|
213 |
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
|
214 |
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
|
215 |
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
|
216 |
else: |
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
217 |
self.SavedMode = True |
0 | 218 |
# 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
|
219 |
if self.Mode != MODE_SELECTION and self.SelectedElement: |
0 | 220 |
self.SelectedElement.SetSelected(False) |
221 |
self.SelectedElement = None |
|
222 |
self.Refresh() |
|
223 |
||
27 | 224 |
# Return current drawing mode |
225 |
def GetDrawingMode(self): |
|
226 |
return self.Parent.GetDrawingMode() |
|
227 |
||
0 | 228 |
#------------------------------------------------------------------------------- |
229 |
# Refresh functions |
|
230 |
#------------------------------------------------------------------------------- |
|
231 |
||
232 |
# Refresh Viewer elements |
|
233 |
def RefreshView(self): |
|
234 |
self.current_id = 0 |
|
235 |
# Start by reseting Viewer |
|
236 |
self.ResetView() |
|
237 |
instance = True |
|
238 |
# List of ids of already loaded blocks |
|
239 |
ids = [] |
|
240 |
# Load Blocks until they are all loaded |
|
241 |
while instance: |
|
242 |
instance = self.Controler.GetCurrentElementEditingInstanceInfos(exclude=ids) |
|
243 |
if instance: |
|
244 |
self.loadInstance(instance, ids) |
|
42 | 245 |
self.RefreshScrollBars() |
0 | 246 |
self.Refresh() |
247 |
||
42 | 248 |
def RefreshScrollBars(self): |
27 | 249 |
xstart, ystart = self.GetViewStart() |
250 |
window_size = self.GetClientSize() |
|
251 |
maxx = maxy = 0 |
|
42 | 252 |
for element in self.GetElements(): |
27 | 253 |
posx, posy = element.GetPosition() |
254 |
width, height = element.GetSize() |
|
255 |
maxx = max(maxx, posx + width) |
|
256 |
maxy = max(maxy, posy + height) |
|
257 |
maxx = max(maxx + WINDOW_BORDER, xstart * SCROLLBAR_UNIT + window_size[0]) |
|
258 |
maxy = max(maxy + WINDOW_BORDER, ystart * SCROLLBAR_UNIT + window_size[1]) |
|
259 |
if self.rubberBand.IsShown(): |
|
260 |
extent = self.rubberBand.GetCurrentExtent() |
|
261 |
maxx = max(maxx, extent.x + extent.width) |
|
262 |
maxy = max(maxy, extent.y + extent.height) |
|
263 |
self.SetScrollbars(SCROLLBAR_UNIT, SCROLLBAR_UNIT, |
|
264 |
maxx / SCROLLBAR_UNIT, maxy / SCROLLBAR_UNIT, xstart, ystart) |
|
265 |
||
0 | 266 |
# Load instance from given informations |
267 |
def loadInstance(self, instance, ids): |
|
268 |
ids.append(instance["id"]) |
|
269 |
self.current_id = max(self.current_id, instance["id"]) |
|
270 |
if instance["type"] == "input": |
|
271 |
variable = FBD_Variable(self, INPUT, instance["name"], instance["value_type"], instance["id"]) |
|
272 |
variable.SetPosition(instance["x"], instance["y"]) |
|
273 |
variable.SetSize(instance["width"], instance["height"]) |
|
42 | 274 |
self.AddBlock(variable) |
0 | 275 |
connectors = variable.GetConnectors() |
276 |
connectors["output"].SetPosition(wxPoint(*instance["connector"]["position"])) |
|
277 |
if instance["connector"]["negated"]: |
|
278 |
connectors["output"].SetNegated(True) |
|
279 |
if instance["connector"]["edge"]: |
|
280 |
connectors["output"].SetEdge(instance["connector"]["edge"]) |
|
281 |
elif instance["type"] == "output": |
|
282 |
variable = FBD_Variable(self, OUTPUT, instance["name"], instance["value_type"], instance["id"]) |
|
283 |
variable.SetPosition(instance["x"], instance["y"]) |
|
284 |
variable.SetSize(instance["width"], instance["height"]) |
|
42 | 285 |
self.AddBlock(variable) |
0 | 286 |
connectors = variable.GetConnectors() |
287 |
connectors["input"].SetPosition(wxPoint(*instance["connector"]["position"])) |
|
288 |
if instance["connector"]["negated"]: |
|
289 |
connectors["input"].SetNegated(True) |
|
290 |
if instance["connector"]["edge"]: |
|
291 |
connectors["input"].SetEdge(instance["connector"]["edge"]) |
|
292 |
self.CreateWires(connectors["input"], instance["connector"]["links"], ids) |
|
293 |
elif instance["type"] == "inout": |
|
294 |
variable = FBD_Variable(self, INOUT, instance["name"], instance["value_type"], instance["id"]) |
|
295 |
variable.SetPosition(instance["x"], instance["y"]) |
|
296 |
variable.SetSize(instance["width"], instance["height"]) |
|
42 | 297 |
self.AddBlock(variable) |
0 | 298 |
connectors = variable.GetConnectors() |
299 |
connectors["output"].SetPosition(wxPoint(*instance["connectors"]["output"]["position"])) |
|
300 |
connectors["input"].SetPosition(wxPoint(*instance["connectors"]["input"]["position"])) |
|
301 |
if instance["connectors"]["output"]["negated"]: |
|
302 |
connectors["output"].SetNegated(True) |
|
303 |
if instance["connectors"]["output"]["edge"]: |
|
304 |
connectors["output"].SetEdge(instance["connectors"]["output"]["edge"]) |
|
305 |
if instance["connectors"]["input"]["negated"]: |
|
306 |
connectors["input"].SetNegated(True) |
|
307 |
if instance["connectors"]["input"]["edge"]: |
|
308 |
connectors["input"].SetEdge(instance["connectors"]["input"]["edge"]) |
|
309 |
self.CreateWires(connectors["input"], instance["connectors"]["input"]["links"], ids) |
|
310 |
elif instance["type"] == "continuation": |
|
311 |
connection = FBD_Connector(self, CONTINUATION, instance["name"], instance["id"]) |
|
312 |
connection.SetPosition(instance["x"], instance["y"]) |
|
313 |
connection.SetSize(instance["width"], instance["height"]) |
|
42 | 314 |
self.AddBlock(connection) |
0 | 315 |
connector = connection.GetConnector() |
316 |
connector.SetPosition(wxPoint(*instance["connector"]["position"])) |
|
317 |
elif instance["type"] == "connection": |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
318 |
connection = FBD_Connector(self, CONNECTOR, instance["name"], instance["id"]) |
0 | 319 |
connection.SetPosition(instance["x"], instance["y"]) |
320 |
connection.SetSize(instance["width"], instance["height"]) |
|
42 | 321 |
self.AddBlock(connection) |
0 | 322 |
connector = connection.GetConnector() |
323 |
connector.SetPosition(wxPoint(*instance["connector"]["position"])) |
|
324 |
self.CreateWires(connector, instance["connector"]["links"], ids) |
|
325 |
elif instance["type"] == "comment": |
|
326 |
comment = Comment(self, instance["content"], instance["id"]) |
|
327 |
comment.SetPosition(instance["x"], instance["y"]) |
|
328 |
comment.SetSize(instance["width"], instance["height"]) |
|
42 | 329 |
self.AddComment(comment) |
0 | 330 |
elif instance["type"] == "leftPowerRail": |
331 |
leftpowerrail = LD_PowerRail(self, LEFTRAIL, instance["id"], [True for i in range(len(instance["connectors"]))]) |
|
332 |
leftpowerrail.SetPosition(instance["x"], instance["y"]) |
|
42 | 333 |
self.AddBlock(leftpowerrail) |
0 | 334 |
connectors = leftpowerrail.GetConnectors() |
335 |
for i, connector in enumerate(instance["connectors"]): |
|
336 |
connectors[i].SetPosition(wxPoint(*connector["position"])) |
|
337 |
elif instance["type"] == "rightPowerRail": |
|
338 |
rightpowerrail = LD_PowerRail(self, RIGHTRAIL, instance["id"], [True for i in range(len(instance["connectors"]))]) |
|
339 |
rightpowerrail.SetPosition(instance["x"], instance["y"]) |
|
42 | 340 |
self.AddBlock(rightpowerrail) |
0 | 341 |
connectors = rightpowerrail.GetConnectors() |
342 |
for i, connector in enumerate(instance["connectors"]): |
|
343 |
connectors[i].SetPosition(wxPoint(*connector["position"])) |
|
344 |
self.CreateWires(connectors[i], connector["links"], ids) |
|
345 |
elif instance["type"] == "contact": |
|
346 |
if instance["negated"]: |
|
347 |
negated = instance["negated"] |
|
348 |
else: |
|
349 |
negated = False |
|
350 |
if instance["edge"]: |
|
351 |
edge = instance["edge"] |
|
352 |
else: |
|
353 |
edge = "none" |
|
354 |
if negated and edge == "none": |
|
355 |
contact_type = CONTACT_REVERSE |
|
356 |
elif not negated and edge == "rising": |
|
357 |
contact_type = CONTACT_RISING |
|
358 |
elif not negated and edge == "falling": |
|
359 |
contact_type = CONTACT_FALLING |
|
360 |
else: |
|
361 |
contact_type = CONTACT_NORMAL |
|
362 |
contact = LD_Contact(self, contact_type, instance["name"], instance["id"]) |
|
363 |
contact.SetPosition(instance["x"], instance["y"]) |
|
42 | 364 |
self.AddBlock(contact) |
0 | 365 |
connectors = contact.GetConnectors() |
366 |
connectors["input"].SetPosition(wxPoint(*instance["connectors"]["input"]["position"])) |
|
367 |
self.CreateWires(connectors["input"], instance["connectors"]["input"]["links"], ids) |
|
368 |
connectors["output"].SetPosition(wxPoint(*instance["connectors"]["output"]["position"])) |
|
369 |
elif instance["type"] == "coil": |
|
370 |
if instance["negated"]: |
|
371 |
negated = instance["negated"] |
|
372 |
else: |
|
373 |
negated = False |
|
374 |
if instance["storage"]: |
|
375 |
storage = instance["storage"] |
|
376 |
else: |
|
377 |
storage = "none" |
|
378 |
if negated and storage == "none": |
|
379 |
coil_type = COIL_REVERSE |
|
380 |
elif not negated and storage == "set": |
|
381 |
coil_type = COIL_SET |
|
382 |
elif not negated and storage == "reset": |
|
383 |
coil_type = COIL_RESET |
|
384 |
else: |
|
385 |
coil_type = COIL_NORMAL |
|
386 |
coil = LD_Coil(self, coil_type, instance["name"], instance["id"]) |
|
387 |
coil.SetPosition(instance["x"], instance["y"]) |
|
42 | 388 |
self.AddBlock(coil) |
0 | 389 |
connectors = coil.GetConnectors() |
390 |
connectors["input"].SetPosition(wxPoint(*instance["connectors"]["input"]["position"])) |
|
391 |
self.CreateWires(connectors["input"], instance["connectors"]["input"]["links"], ids) |
|
392 |
connectors["output"].SetPosition(wxPoint(*instance["connectors"]["output"]["position"])) |
|
393 |
elif instance["type"] == "step": |
|
394 |
if instance["initial"]: |
|
395 |
initial = instance["initial"] |
|
396 |
else: |
|
397 |
initial = False |
|
398 |
step = SFC_Step(self, instance["name"], initial, instance["id"]) |
|
399 |
step.SetPosition(instance["x"], instance["y"]) |
|
400 |
step.SetSize(instance["width"], instance["height"]) |
|
42 | 401 |
self.AddBlock(step) |
0 | 402 |
if "output" in instance["connectors"]: |
403 |
step.AddOutput() |
|
404 |
if "action" in instance["connectors"]: |
|
405 |
step.AddAction() |
|
406 |
connectors = step.GetConnectors() |
|
407 |
if connectors["input"]: |
|
408 |
connectors["input"].SetPosition(wxPoint(*instance["connectors"]["input"]["position"])) |
|
409 |
self.CreateWires(connectors["input"], instance["connectors"]["input"]["links"], ids) |
|
410 |
if connectors["output"]: |
|
411 |
connectors["output"].SetPosition(wxPoint(*instance["connectors"]["output"]["position"])) |
|
412 |
if connectors["action"]: |
|
413 |
connectors["action"].SetPosition(wxPoint(*instance["connectors"]["action"]["position"])) |
|
414 |
elif instance["type"] == "transition": |
|
415 |
transition = SFC_Transition(self, instance["condition_type"], instance["condition"], instance["id"]) |
|
416 |
transition.SetPosition(instance["x"], instance["y"]) |
|
42 | 417 |
self.AddBlock(transition) |
0 | 418 |
connectors = transition.GetConnectors() |
419 |
connectors["input"].SetPosition(wxPoint(*instance["connectors"]["input"]["position"])) |
|
420 |
self.CreateWires(connectors["input"], instance["connectors"]["input"]["links"], ids) |
|
421 |
connectors["output"].SetPosition(wxPoint(*instance["connectors"]["output"]["position"])) |
|
422 |
elif instance["type"] in ["selectionDivergence", "selectionConvergence", "simultaneousDivergence", "simultaneousConvergence"]: |
|
423 |
if instance["type"] == "selectionDivergence": |
|
424 |
divergence = SFC_Divergence(self, SELECTION_DIVERGENCE, |
|
425 |
len(instance["connectors"]["outputs"]), instance["id"]) |
|
426 |
elif instance["type"] == "selectionConvergence": |
|
427 |
divergence = SFC_Divergence(self, SELECTION_CONVERGENCE, |
|
428 |
len(instance["connectors"]["inputs"]), instance["id"]) |
|
429 |
elif instance["type"] == "simultaneousDivergence": |
|
430 |
divergence = SFC_Divergence(self, SIMULTANEOUS_DIVERGENCE, |
|
431 |
len(instance["connectors"]["outputs"]), instance["id"]) |
|
432 |
else: |
|
433 |
divergence = SFC_Divergence(self, SIMULTANEOUS_CONVERGENCE, |
|
434 |
len(instance["connectors"]["inputs"]), instance["id"]) |
|
435 |
divergence.SetPosition(instance["x"], instance["y"]) |
|
436 |
divergence.SetSize(instance["width"], instance["height"]) |
|
42 | 437 |
self.AddBlock(divergence) |
0 | 438 |
connectors = divergence.GetConnectors() |
439 |
for i, input_connector in enumerate(instance["connectors"]["inputs"]): |
|
440 |
connector = connectors["inputs"][i] |
|
441 |
connector.SetPosition(wxPoint(*input_connector["position"])) |
|
442 |
self.CreateWires(connector, input_connector["links"], ids) |
|
443 |
for i, output_connector in enumerate(instance["connectors"]["outputs"]): |
|
444 |
connector = connectors["outputs"][i] |
|
445 |
connector.SetPosition(wxPoint(*output_connector["position"])) |
|
446 |
elif instance["type"] == "jump": |
|
447 |
jump = SFC_Jump(self, instance["target"], instance["id"]) |
|
448 |
jump.SetPosition(instance["x"], instance["y"]) |
|
42 | 449 |
self.AddBlock(jump) |
0 | 450 |
connector = jump.GetConnector() |
451 |
connector.SetPosition(wxPoint(*instance["connector"]["position"])) |
|
452 |
self.CreateWires(connector, instance["connector"]["links"], ids) |
|
453 |
elif instance["type"] == "actionBlock": |
|
454 |
actionBlock = SFC_ActionBlock(self, instance["actions"], instance["id"]) |
|
455 |
actionBlock.SetPosition(instance["x"], instance["y"]) |
|
456 |
actionBlock.SetSize(instance["width"], instance["height"]) |
|
42 | 457 |
self.AddBlock(actionBlock) |
0 | 458 |
connector = actionBlock.GetConnector() |
459 |
connector.SetPosition(wxPoint(*instance["connector"]["position"])) |
|
460 |
self.CreateWires(connector, instance["connector"]["links"], ids) |
|
461 |
else: |
|
462 |
if instance["name"] != None: |
|
463 |
block = FBD_Block(self, instance["type"], instance["name"], instance["id"], len(instance["connectors"]["inputs"])) |
|
464 |
else: |
|
465 |
block = FBD_Block(self, instance["type"], "", instance["id"], len(instance["connectors"]["inputs"])) |
|
466 |
block.SetPosition(instance["x"], instance["y"]) |
|
467 |
block.SetSize(instance["width"], instance["height"]) |
|
42 | 468 |
self.AddBlock(block) |
0 | 469 |
connectors = block.GetConnectors() |
470 |
for i, input_connector in enumerate(instance["connectors"]["inputs"]): |
|
471 |
connector = connectors["inputs"][i] |
|
472 |
connector.SetPosition(wxPoint(*input_connector["position"])) |
|
473 |
if input_connector["negated"]: |
|
474 |
connector.SetNegated(True) |
|
475 |
if input_connector["edge"]: |
|
476 |
connector.SetEdge(input_connector["edge"]) |
|
477 |
self.CreateWires(connector, input_connector["links"], ids) |
|
478 |
for i, output_connector in enumerate(instance["connectors"]["outputs"]): |
|
479 |
connector = connectors["outputs"][i] |
|
480 |
if output_connector["negated"]: |
|
481 |
connector.SetNegated(True) |
|
482 |
if output_connector["edge"]: |
|
483 |
connector.SetEdge(output_connector["edge"]) |
|
484 |
connector.SetPosition(wxPoint(*output_connector["position"])) |
|
485 |
||
486 |
def CreateWires(self, start_connector, links, ids): |
|
487 |
for link in links: |
|
488 |
refLocalId = link["refLocalId"] |
|
489 |
if refLocalId != None: |
|
490 |
if refLocalId not in ids: |
|
491 |
new_instance = self.Controler.GetCurrentElementEditingInstanceInfos(refLocalId) |
|
492 |
if new_instance: |
|
493 |
self.loadInstance(new_instance, ids) |
|
494 |
connected = self.FindElementById(refLocalId) |
|
495 |
if connected: |
|
496 |
points = link["points"] |
|
27 | 497 |
end_connector = connected.GetConnector(wxPoint(points[-1][0], points[-1][1]), link["formalParameter"]) |
0 | 498 |
if end_connector: |
499 |
wire = Wire(self) |
|
500 |
wire.SetPoints(points) |
|
501 |
start_connector.Connect((wire, 0), False) |
|
502 |
end_connector.Connect((wire, -1), False) |
|
503 |
wire.ConnectStartPoint(None, start_connector) |
|
504 |
wire.ConnectEndPoint(None, end_connector) |
|
42 | 505 |
self.AddWire(wire) |
0 | 506 |
|
507 |
#------------------------------------------------------------------------------- |
|
508 |
# Search Element functions |
|
509 |
#------------------------------------------------------------------------------- |
|
510 |
||
511 |
def FindBlock(self, pos): |
|
512 |
for block in self.Blocks: |
|
513 |
if block.HitTest(pos) or block.TestHandle(pos) != (0, 0): |
|
514 |
return block |
|
515 |
return None |
|
516 |
||
517 |
def FindWire(self, pos): |
|
518 |
for wire in self.Wires: |
|
519 |
if wire.HitTest(pos) or wire.TestHandle(pos) != (0, 0): |
|
520 |
return wire |
|
521 |
return None |
|
522 |
||
523 |
def FindElement(self, pos, exclude_group = False): |
|
524 |
if self.SelectedElement and not (exclude_group and isinstance(self.SelectedElement, Graphic_Group)): |
|
525 |
if self.SelectedElement.HitTest(pos) or self.SelectedElement.TestHandle(pos) != (0, 0): |
|
526 |
return self.SelectedElement |
|
42 | 527 |
for element in self.GetElements(): |
0 | 528 |
if element.HitTest(pos) or element.TestHandle(pos) != (0, 0): |
529 |
return element |
|
530 |
return None |
|
531 |
||
3
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
532 |
def FindBlockConnector(self, pos, exclude = True): |
0 | 533 |
for block in self.Blocks: |
3
86ccc89d7b0b
FBD Blocks and Variables can now be modified and wires can't be unconnected on both sides
lbessard
parents:
2
diff
changeset
|
534 |
result = block.TestConnector(pos, exclude) |
0 | 535 |
if result: |
536 |
return result |
|
537 |
return None |
|
538 |
||
539 |
def FindElementById(self, id): |
|
42 | 540 |
for element in self.Blocks: |
541 |
if element.GetId() == id: |
|
542 |
return element |
|
543 |
for element in self.Comments: |
|
0 | 544 |
if element.GetId() == id: |
545 |
return element |
|
546 |
return None |
|
547 |
||
548 |
def SearchElements(self, bbox): |
|
549 |
elements = [] |
|
42 | 550 |
for element in self.GetElements(): |
551 |
if element.IsInSelection(bbox): |
|
0 | 552 |
elements.append(element) |
553 |
return elements |
|
554 |
||
555 |
#------------------------------------------------------------------------------- |
|
556 |
# Popup menu functions |
|
557 |
#------------------------------------------------------------------------------- |
|
558 |
||
559 |
def PopupBlockMenu(self, connector = None): |
|
13
69075340d6a9
Adding support for forbidding insertion of function block into function
lbessard
parents:
10
diff
changeset
|
560 |
type = self.Controler.GetCurrentElementEditingType() |
0 | 561 |
self.ContextualMenu.FindItemByPosition(0).Enable(connector != None) |
562 |
self.ContextualMenu.FindItemByPosition(1).Enable(connector != None) |
|
13
69075340d6a9
Adding support for forbidding insertion of function block into function
lbessard
parents:
10
diff
changeset
|
563 |
self.ContextualMenu.FindItemByPosition(2).Enable(connector != None and type != "function") |
69075340d6a9
Adding support for forbidding insertion of function block into function
lbessard
parents:
10
diff
changeset
|
564 |
self.ContextualMenu.FindItemByPosition(3).Enable(connector != None and type != "function") |
0 | 565 |
self.ContextualMenu.FindItemByPosition(5).Enable(False) |
566 |
self.ContextualMenu.FindItemByPosition(6).Enable(False) |
|
567 |
self.ContextualMenu.FindItemByPosition(8).Enable(False) |
|
568 |
self.ContextualMenu.FindItemByPosition(9).Enable(False) |
|
569 |
if connector: |
|
570 |
if connector.IsNegated(): |
|
571 |
self.ContextualMenu.FindItemByPosition(1).Check(True) |
|
572 |
elif connector.GetEdge() == "rising": |
|
573 |
self.ContextualMenu.FindItemByPosition(2).Check(True) |
|
574 |
elif connector.GetEdge() == "falling": |
|
575 |
self.ContextualMenu.FindItemByPosition(3).Check(True) |
|
576 |
else: |
|
577 |
self.ContextualMenu.FindItemByPosition(0).Check(True) |
|
578 |
self.PopupMenu(self.ContextualMenu) |
|
579 |
||
580 |
def PopupVariableMenu(self, connector = None): |
|
581 |
self.ContextualMenu.FindItemByPosition(0).Enable(connector != None) |
|
582 |
self.ContextualMenu.FindItemByPosition(1).Enable(connector != None) |
|
583 |
self.ContextualMenu.FindItemByPosition(2).Enable(False) |
|
584 |
self.ContextualMenu.FindItemByPosition(3).Enable(False) |
|
585 |
self.ContextualMenu.FindItemByPosition(5).Enable(False) |
|
586 |
self.ContextualMenu.FindItemByPosition(6).Enable(False) |
|
587 |
self.ContextualMenu.FindItemByPosition(8).Enable(False) |
|
588 |
self.ContextualMenu.FindItemByPosition(9).Enable(False) |
|
589 |
if connector: |
|
590 |
if connector.IsNegated(): |
|
591 |
self.ContextualMenu.FindItemByPosition(1).Check(True) |
|
592 |
else: |
|
593 |
self.ContextualMenu.FindItemByPosition(0).Check(True) |
|
594 |
self.PopupMenu(self.ContextualMenu) |
|
595 |
||
596 |
def PopupWireMenu(self): |
|
597 |
self.ContextualMenu.FindItemByPosition(0).Enable(False) |
|
598 |
self.ContextualMenu.FindItemByPosition(1).Enable(False) |
|
599 |
self.ContextualMenu.FindItemByPosition(2).Enable(False) |
|
600 |
self.ContextualMenu.FindItemByPosition(3).Enable(False) |
|
601 |
self.ContextualMenu.FindItemByPosition(5).Enable(True) |
|
602 |
self.ContextualMenu.FindItemByPosition(6).Enable(True) |
|
603 |
self.ContextualMenu.FindItemByPosition(8).Enable(False) |
|
604 |
self.ContextualMenu.FindItemByPosition(9).Enable(False) |
|
605 |
self.PopupMenu(self.ContextualMenu) |
|
606 |
||
607 |
def PopupDivergenceMenu(self, connector): |
|
608 |
self.ContextualMenu.FindItemByPosition(0).Enable(False) |
|
609 |
self.ContextualMenu.FindItemByPosition(1).Enable(False) |
|
610 |
self.ContextualMenu.FindItemByPosition(2).Enable(False) |
|
611 |
self.ContextualMenu.FindItemByPosition(3).Enable(False) |
|
612 |
self.ContextualMenu.FindItemByPosition(5).Enable(False) |
|
613 |
self.ContextualMenu.FindItemByPosition(6).Enable(False) |
|
614 |
self.ContextualMenu.FindItemByPosition(8).Enable(True) |
|
615 |
self.ContextualMenu.FindItemByPosition(9).Enable(connector) |
|
616 |
self.PopupMenu(self.ContextualMenu) |
|
617 |
||
618 |
def PopupDefaultMenu(self): |
|
619 |
self.ContextualMenu.FindItemByPosition(0).Enable(False) |
|
620 |
self.ContextualMenu.FindItemByPosition(1).Enable(False) |
|
621 |
self.ContextualMenu.FindItemByPosition(2).Enable(False) |
|
622 |
self.ContextualMenu.FindItemByPosition(3).Enable(False) |
|
623 |
self.ContextualMenu.FindItemByPosition(5).Enable(False) |
|
624 |
self.ContextualMenu.FindItemByPosition(6).Enable(False) |
|
625 |
self.ContextualMenu.FindItemByPosition(8).Enable(False) |
|
626 |
self.ContextualMenu.FindItemByPosition(9).Enable(False) |
|
627 |
self.PopupMenu(self.ContextualMenu) |
|
628 |
||
629 |
def EditCommentContent(self, comment): |
|
630 |
dialog = wxTextEntryDialog(self.Parent, "Edit comment", "Please enter comment text", comment.GetContent(), wxOK|wxCANCEL|wxTE_MULTILINE) |
|
631 |
if dialog.ShowModal() == wxID_OK: |
|
632 |
value = dialog.GetValue() |
|
633 |
comment.SetContent(value) |
|
634 |
infos = {"content" : value} |
|
635 |
infos["width"], infos["height"] = comment.GetSize() |
|
636 |
self.Controler.SetCurrentElementEditingCommentInfos(comment.GetId(), infos) |
|
637 |
self.Refresh() |
|
638 |
dialog.Destroy() |
|
639 |
||
640 |
#------------------------------------------------------------------------------- |
|
641 |
# Menu items functions |
|
642 |
#------------------------------------------------------------------------------- |
|
643 |
||
644 |
def OnNoModifierMenu(self, event): |
|
42 | 645 |
if self.SelectedElement and self.IsBlock(self.SelectedElement): |
0 | 646 |
self.SelectedElement.SetConnectorNegated(False) |
647 |
event.Skip() |
|
648 |
||
649 |
def OnNegatedMenu(self, event): |
|
42 | 650 |
if self.SelectedElement and self.IsBlock(self.SelectedElement): |
0 | 651 |
self.SelectedElement.SetConnectorNegated(True) |
652 |
event.Skip() |
|
653 |
||
654 |
def OnRisingEdgeMenu(self, event): |
|
42 | 655 |
if self.SelectedElement and self.IsBlock(self.SelectedElement): |
0 | 656 |
self.SelectedElement.SetConnectorEdge("rising") |
657 |
event.Skip() |
|
658 |
||
659 |
def OnFallingEdgeMenu(self, event): |
|
42 | 660 |
if self.SelectedElement and self.IsBlock(self.SelectedElement): |
0 | 661 |
self.SelectedElement.SetConnectorEdge("falling") |
662 |
event.Skip() |
|
663 |
||
664 |
def OnAddSegmentMenu(self, event): |
|
42 | 665 |
if self.SelectedElement and self.IsBlock(self.SelectedElement): |
0 | 666 |
self.SelectedElement.AddSegment() |
667 |
event.Skip() |
|
668 |
||
669 |
def OnDeleteSegmentMenu(self, event): |
|
42 | 670 |
if self.SelectedElement and self.IsBlock(self.SelectedElement): |
0 | 671 |
self.SelectedElement.DeleteSegment() |
672 |
event.Skip() |
|
673 |
||
674 |
def OnAddBranchMenu(self, event): |
|
42 | 675 |
if self.SelectedElement and self.IsBlock(self.SelectedElement): |
0 | 676 |
self.AddDivergenceBranch(self.SelectedElement) |
677 |
event.Skip() |
|
678 |
||
679 |
def OnDeleteBranchMenu(self, event): |
|
42 | 680 |
if self.SelectedElement and self.IsBlock(self.SelectedElement): |
0 | 681 |
self.RemoveDivergenceBranch(self.SelectedElement) |
682 |
event.Skip() |
|
683 |
||
684 |
def OnDeleteMenu(self, event): |
|
685 |
if self.SelectedElement: |
|
686 |
self.SelectedElement.Delete() |
|
687 |
self.SelectedElement = None |
|
688 |
event.Skip() |
|
689 |
||
690 |
#------------------------------------------------------------------------------- |
|
691 |
# Mouse event functions |
|
692 |
#------------------------------------------------------------------------------- |
|
693 |
||
694 |
def OnViewerLeftDown(self, event): |
|
27 | 695 |
if self.Mode == MODE_SELECTION: |
696 |
dc = self.GetLogicalDC() |
|
697 |
pos = event.GetLogicalPosition(dc) |
|
698 |
if event.ControlDown() and self.SelectedElement: |
|
699 |
element = self.FindElement(pos, True) |
|
700 |
if element: |
|
701 |
if isinstance(self.SelectedElement, Graphic_Group): |
|
702 |
self.SelectedElement.SetSelected(False) |
|
703 |
self.SelectedElement.SelectElement(element) |
|
704 |
elif self.SelectedElement: |
|
705 |
group = Graphic_Group(self) |
|
706 |
group.SelectElement(self.SelectedElement) |
|
707 |
group.SelectElement(element) |
|
708 |
self.SelectedElement = group |
|
709 |
elements = self.SelectedElement.GetElements() |
|
710 |
if len(elements) == 0: |
|
711 |
self.SelectedElement = element |
|
712 |
elif len(elements) == 1: |
|
713 |
self.SelectedElement = elements[0] |
|
714 |
self.SelectedElement.SetSelected(True) |
|
715 |
else: |
|
716 |
element = self.FindElement(pos) |
|
717 |
if self.SelectedElement and self.SelectedElement != element: |
|
718 |
self.SelectedElement.SetSelected(False) |
|
719 |
self.SelectedElement = None |
|
720 |
self.Refresh() |
|
721 |
if element: |
|
722 |
self.SelectedElement = element |
|
723 |
self.SelectedElement.OnLeftDown(event, dc, self.Scaling) |
|
724 |
self.Refresh() |
|
725 |
else: |
|
726 |
self.rubberBand.Reset() |
|
727 |
self.rubberBand.OnLeftDown(event, dc, self.Scaling) |
|
728 |
elif self.Mode in [MODE_BLOCK, MODE_VARIABLE, MODE_CONNECTION, MODE_COMMENT, |
|
729 |
MODE_CONTACT, MODE_COIL, MODE_POWERRAIL, MODE_INITIALSTEP, |
|
730 |
MODE_STEP, MODE_TRANSITION, MODE_DIVERGENCE, MODE_JUMP, MODE_ACTION]: |
|
731 |
self.rubberBand.Reset() |
|
732 |
self.rubberBand.OnLeftDown(event, self.GetLogicalDC(), self.Scaling) |
|
733 |
elif self.Mode == MODE_WIRE: |
|
734 |
pos = GetScaledEventPosition(event, self.GetLogicalDC(), self.Scaling) |
|
735 |
connector = self.FindBlockConnector(pos) |
|
736 |
if connector: |
|
737 |
if (connector.GetDirection() == EAST): |
|
738 |
wire = Wire(self, [wxPoint(pos.x, pos.y), EAST], [wxPoint(pos.x, pos.y), WEST]) |
|
739 |
else: |
|
740 |
wire = Wire(self, [wxPoint(pos.x, pos.y), WEST], [wxPoint(pos.x, pos.y), EAST]) |
|
741 |
wire.oldPos = pos |
|
742 |
wire.Handle = (HANDLE_POINT, 0) |
|
743 |
wire.ProcessDragging(0, 0) |
|
744 |
wire.Handle = (HANDLE_POINT, 1) |
|
42 | 745 |
self.AddWire(wire) |
27 | 746 |
if self.SelectedElement: |
747 |
self.SelectedElement.SetSelected(False) |
|
748 |
self.SelectedElement = wire |
|
749 |
elif self.SelectedElement: |
|
750 |
self.SelectedElement.SetSelected(False) |
|
751 |
self.SelectedElement = None |
|
752 |
self.Refresh() |
|
0 | 753 |
event.Skip() |
754 |
||
755 |
def OnViewerLeftUp(self, event): |
|
27 | 756 |
if self.rubberBand.IsShown(): |
757 |
if self.Mode == MODE_SELECTION: |
|
758 |
elements = self.SearchElements(self.rubberBand.GetCurrentExtent()) |
|
759 |
self.rubberBand.OnLeftUp(event, self.GetLogicalDC(), self.Scaling) |
|
760 |
if len(elements) > 0: |
|
761 |
self.SelectedElement = Graphic_Group(self) |
|
762 |
self.SelectedElement.SetElements(elements) |
|
763 |
self.SelectedElement.SetSelected(True) |
|
764 |
self.Refresh() |
|
765 |
else: |
|
766 |
bbox = self.rubberBand.GetCurrentExtent() |
|
767 |
self.rubberBand.OnLeftUp(event, self.GetLogicalDC(), self.Scaling) |
|
768 |
if self.Mode == MODE_BLOCK: |
|
769 |
wxCallAfter(self.AddNewBlock, bbox) |
|
770 |
elif self.Mode == MODE_VARIABLE: |
|
771 |
wxCallAfter(self.AddNewVariable, bbox) |
|
772 |
elif self.Mode == MODE_CONNECTION: |
|
773 |
wxCallAfter(self.AddNewConnection, bbox) |
|
774 |
elif self.Mode == MODE_COMMENT: |
|
775 |
wxCallAfter(self.AddNewComment, bbox) |
|
776 |
elif self.Mode == MODE_CONTACT: |
|
777 |
wxCallAfter(self.AddNewContact, bbox) |
|
778 |
elif self.Mode == MODE_COIL: |
|
779 |
wxCallAfter(self.AddNewContact, bbox) |
|
780 |
elif self.Mode == MODE_POWERRAIL: |
|
781 |
wxCallAfter(self.AddNewPowerRail, bbox) |
|
782 |
elif self.Mode == MODE_INITIALSTEP: |
|
783 |
wxCallAfter(self.AddNewInitialStep, bbox) |
|
784 |
elif self.Mode == MODE_STEP: |
|
785 |
wxCallAfter(self.AddNewStep, bbox) |
|
786 |
elif self.Mode == MODE_TRANSITION: |
|
787 |
wxCallAfter(self.AddNewTransition, bbox) |
|
788 |
elif self.Mode == MODE_DIVERGENCE: |
|
789 |
wxCallAfter(self.AddNewDivergence, bbox) |
|
790 |
elif self.Mode == MODE_JUMP: |
|
791 |
wxCallAfter(self.AddNewJump, bbox) |
|
792 |
elif self.Mode == MODE_ACTION: |
|
793 |
wxCallAfter(self.AddNewActionBlock, bbox) |
|
794 |
elif self.Mode == MODE_SELECTION and self.SelectedElement: |
|
795 |
self.SelectedElement.OnLeftUp(event, self.GetLogicalDC(), self.Scaling) |
|
796 |
wxCallAfter(self.SetCursor, wxNullCursor) |
|
797 |
self.ReleaseMouse() |
|
798 |
self.Refresh() |
|
799 |
elif self.Mode == MODE_WIRE and self.SelectedElement: |
|
42 | 800 |
if self.SelectedElement.EndConnected != None: |
27 | 801 |
self.SelectedElement.ResetPoints() |
45 | 802 |
self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling) |
27 | 803 |
self.SelectedElement.GeneratePoints() |
804 |
self.SelectedElement.RefreshModel() |
|
805 |
self.SelectedElement.SetSelected(True) |
|
806 |
else: |
|
807 |
self.SelectedElement.Delete() |
|
808 |
self.SelectedElement = None |
|
809 |
self.Refresh() |
|
810 |
if not self.SavedMode: |
|
811 |
wxCallAfter(self.Parent.ResetCurrentMode) |
|
0 | 812 |
event.Skip() |
813 |
||
814 |
def OnViewerRightUp(self, event): |
|
27 | 815 |
pos = event.GetPosition() |
816 |
element = self.FindElement(pos) |
|
817 |
if element: |
|
818 |
if self.SelectedElement and self.SelectedElement != element: |
|
819 |
self.SelectedElement.SetSelected(False) |
|
820 |
self.SelectedElement = element |
|
821 |
self.SelectedElement.SetSelected(True) |
|
822 |
self.SelectedElement.OnRightUp(event, self.GetLogicalDC(), self.Scaling) |
|
823 |
wxCallAfter(self.SetCursor, wxNullCursor) |
|
824 |
self.ReleaseMouse() |
|
825 |
self.Refresh() |
|
0 | 826 |
event.Skip() |
827 |
||
828 |
def OnViewerLeftDClick(self, event): |
|
27 | 829 |
if self.Mode == MODE_SELECTION and self.SelectedElement: |
830 |
self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling) |
|
831 |
self.Refresh() |
|
0 | 832 |
event.Skip() |
833 |
||
834 |
def OnViewerMotion(self, event): |
|
27 | 835 |
if self.rubberBand.IsShown(): |
836 |
self.rubberBand.OnMotion(event, self.GetLogicalDC(), self.Scaling) |
|
837 |
elif self.Mode == MODE_SELECTION and self.SelectedElement: |
|
838 |
self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling) |
|
839 |
self.Refresh() |
|
840 |
elif self.Mode == MODE_WIRE and self.SelectedElement: |
|
841 |
dc = self.GetLogicalDC() |
|
842 |
pos = GetScaledEventPosition(event, dc, self.Scaling) |
|
843 |
connector = self.FindBlockConnector(pos, False) |
|
844 |
if not connector or self.SelectedElement.EndConnected == None: |
|
845 |
self.SelectedElement.ResetPoints() |
|
846 |
self.SelectedElement.OnMotion(event, dc, self.Scaling) |
|
847 |
self.SelectedElement.GeneratePoints() |
|
848 |
self.Refresh() |
|
849 |
if (event.Dragging() and self.SelectedElement) or self.rubberBand.IsShown(): |
|
850 |
position = event.GetPosition() |
|
851 |
move_window = wxPoint() |
|
852 |
window_size = self.GetClientSize() |
|
853 |
xstart, ystart = self.GetViewStart() |
|
854 |
if position.x < SCROLL_ZONE and xstart > 0: |
|
855 |
move_window.x = -1 |
|
856 |
elif position.x > window_size[0] - SCROLL_ZONE: |
|
857 |
move_window.x = 1 |
|
858 |
if position.y < SCROLL_ZONE and ystart > 0: |
|
859 |
move_window.y = -1 |
|
860 |
elif position.y > window_size[1] - SCROLL_ZONE: |
|
861 |
move_window.y = 1 |
|
862 |
if move_window.x != 0 or move_window.y != 0: |
|
863 |
self.Scroll(xstart + move_window.x, ystart + move_window.y) |
|
42 | 864 |
self.RefreshScrollBars() |
0 | 865 |
event.Skip() |
866 |
||
867 |
#------------------------------------------------------------------------------- |
|
868 |
# Keyboard event functions |
|
869 |
#------------------------------------------------------------------------------- |
|
870 |
||
871 |
def OnChar(self, event): |
|
42 | 872 |
xpos, ypos = self.GetScrollPos(wxHORIZONTAL), self.GetScrollPos(wxVERTICAL) |
873 |
xmax = self.GetScrollRange(wxHORIZONTAL) - self.GetScrollThumb(wxHORIZONTAL) |
|
874 |
ymax = self.GetScrollRange(wxVERTICAL) - self.GetScrollThumb(wxVERTICAL) |
|
27 | 875 |
keycode = event.GetKeyCode() |
876 |
if self.Scaling: |
|
877 |
scaling = self.Scaling |
|
878 |
else: |
|
879 |
scaling = (8, 8) |
|
880 |
if keycode == WXK_DELETE and self.SelectedElement: |
|
881 |
self.SelectedElement.Clean() |
|
882 |
self.SelectedElement.Delete() |
|
883 |
self.SelectedElement = None |
|
42 | 884 |
elif keycode == WXK_LEFT: |
885 |
if event.ControlDown() and event.ShiftDown(): |
|
886 |
self.Scroll(0, ypos) |
|
887 |
elif event.ControlDown(): |
|
888 |
self.Scroll(max(0, xpos - 1), ypos) |
|
889 |
elif self.SelectedElement: |
|
890 |
self.SelectedElement.Move(-scaling[0], 0) |
|
891 |
elif keycode == WXK_RIGHT: |
|
892 |
if event.ControlDown() and event.ShiftDown(): |
|
893 |
self.Scroll(xmax, ypos) |
|
894 |
elif event.ControlDown(): |
|
895 |
self.Scroll(min(xpos + 1, xmax), ypos) |
|
896 |
elif self.SelectedElement: |
|
897 |
self.SelectedElement.Move(scaling[0], 0) |
|
898 |
elif keycode == WXK_UP: |
|
899 |
if event.ControlDown() and event.ShiftDown(): |
|
900 |
self.Scroll(xpos, 0) |
|
901 |
elif event.ControlDown(): |
|
902 |
self.Scroll(xpos, max(0, ypos - 1)) |
|
903 |
elif self.SelectedElement: |
|
904 |
self.SelectedElement.Move(0, -scaling[1]) |
|
905 |
elif keycode == WXK_DOWN: |
|
906 |
if event.ControlDown() and event.ShiftDown(): |
|
907 |
self.Scroll(xpos, ymax) |
|
908 |
elif event.ControlDown(): |
|
909 |
self.Scroll(xpos, min(ypos + 1, ymax)) |
|
910 |
elif self.SelectedElement: |
|
911 |
self.SelectedElement.Move(0, scaling[1]) |
|
27 | 912 |
self.Refresh() |
913 |
||
914 |
#------------------------------------------------------------------------------- |
|
915 |
# Model adding functions |
|
916 |
#------------------------------------------------------------------------------- |
|
917 |
||
918 |
def AddNewBlock(self, bbox): |
|
919 |
dialog = BlockPropertiesDialog(self.Parent) |
|
920 |
dialog.SetBlockList(self.Controler.GetBlockTypes()) |
|
921 |
dialog.SetMinBlockSize((bbox.width, bbox.height)) |
|
922 |
if dialog.ShowModal() == wxID_OK: |
|
923 |
id = self.GetNewId() |
|
924 |
values = dialog.GetValues() |
|
925 |
if "name" in values: |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
926 |
block = FBD_Block(self, values["type"], values["name"], id, values["extension"], values["inputs"]) |
27 | 927 |
else: |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
928 |
block = FBD_Block(self, values["type"], "", id, values["extension"], values["inputs"]) |
27 | 929 |
block.SetPosition(bbox.x, bbox.y) |
930 |
block.SetSize(values["width"], values["height"]) |
|
42 | 931 |
self.AddBlock(block) |
27 | 932 |
self.Controler.AddCurrentElementEditingBlock(id) |
933 |
self.RefreshBlockModel(block) |
|
42 | 934 |
self.RefreshScrollBars() |
27 | 935 |
self.Refresh() |
936 |
dialog.Destroy() |
|
937 |
||
938 |
def AddNewVariable(self, bbox): |
|
939 |
dialog = VariablePropertiesDialog(self.Parent) |
|
940 |
dialog.SetMinVariableSize((bbox.width, bbox.height)) |
|
941 |
varlist = [] |
|
942 |
vars = self.Controler.GetCurrentElementEditingInterfaceVars() |
|
943 |
if vars: |
|
944 |
for var in vars: |
|
945 |
varlist.append((var["Name"], var["Class"], var["Type"])) |
|
946 |
returntype = self.Controler.GetCurrentElementEditingInterfaceReturnType() |
|
947 |
if returntype: |
|
948 |
varlist.append((self.Controler.GetCurrentElementEditingName(), "Output", returntype)) |
|
949 |
dialog.SetVariables(varlist) |
|
950 |
if dialog.ShowModal() == wxID_OK: |
|
951 |
id = self.GetNewId() |
|
952 |
values = dialog.GetValues() |
|
953 |
variable = FBD_Variable(self, values["type"], values["name"], values["value_type"], id) |
|
954 |
variable.SetPosition(bbox.x, bbox.y) |
|
955 |
variable.SetSize(values["width"], values["height"]) |
|
42 | 956 |
self.AddBlock(variable) |
27 | 957 |
self.Controler.AddCurrentElementEditingVariable(id, values["type"]) |
958 |
self.RefreshVariableModel(variable) |
|
42 | 959 |
self.RefreshScrollBars() |
27 | 960 |
self.Refresh() |
961 |
dialog.Destroy() |
|
962 |
||
963 |
def AddNewConnection(self, bbox): |
|
964 |
dialog = ConnectionPropertiesDialog(self.Parent) |
|
965 |
dialog.SetMinConnectionSize((bbox.width, bbox.height)) |
|
966 |
if dialog.ShowModal() == wxID_OK: |
|
967 |
id = self.GetNewId() |
|
968 |
values = dialog.GetValues() |
|
969 |
connection = FBD_Connector(self, values["type"], values["name"], id) |
|
970 |
connection.SetPosition(bbox.x, bbox.y) |
|
971 |
connection.SetSize(values["width"], values["height"]) |
|
42 | 972 |
self.AddBlock(connection) |
27 | 973 |
self.Controler.AddCurrentElementEditingConnection(id, values["type"]) |
974 |
self.RefreshConnectionModel(connection) |
|
42 | 975 |
self.RefreshScrollBars() |
27 | 976 |
self.Refresh() |
977 |
dialog.Destroy() |
|
978 |
||
979 |
def AddNewComment(self, bbox): |
|
980 |
dialog = wxTextEntryDialog(self.Parent, "Add a new comment", "Please enter comment text", "", wxOK|wxCANCEL|wxTE_MULTILINE) |
|
981 |
if dialog.ShowModal() == wxID_OK: |
|
982 |
value = dialog.GetValue() |
|
983 |
id = self.GetNewId() |
|
984 |
comment = Comment(self, value, id) |
|
985 |
comment.SetPosition(bbox.x, bbox.y) |
|
986 |
min_width, min_height = comment.GetMinSize() |
|
987 |
comment.SetSize(max(min_width,bbox.width),max(min_height,bbox.height)) |
|
42 | 988 |
self.AddComment(comment) |
27 | 989 |
self.Controler.AddCurrentElementEditingComment(id) |
990 |
self.RefreshCommentModel(comment) |
|
42 | 991 |
self.RefreshScrollBars() |
27 | 992 |
self.Refresh() |
993 |
dialog.Destroy() |
|
994 |
||
995 |
def AddNewContact(self, bbox): |
|
996 |
dialog = LDElementDialog(self.Parent, "contact") |
|
997 |
varlist = [] |
|
998 |
vars = self.Controler.GetCurrentElementEditingInterfaceVars() |
|
999 |
if vars: |
|
1000 |
for var in vars: |
|
1001 |
if var["Class"] != "Output" and var["Type"] == "BOOL": |
|
1002 |
varlist.append(var["Name"]) |
|
1003 |
dialog.SetVariables(varlist) |
|
1004 |
dialog.SetValues({"name":"","type":CONTACT_NORMAL}) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1005 |
dialog.SetElementSize((bbox.width, bbox.height)) |
27 | 1006 |
if dialog.ShowModal() == wxID_OK: |
1007 |
id = self.GetNewId() |
|
1008 |
values = dialog.GetValues() |
|
1009 |
contact = LD_Contact(self, values["type"], values["name"], id) |
|
1010 |
contact.SetPosition(bbox.x, bbox.y) |
|
1011 |
contact.SetSize(values["width"], values["height"]) |
|
42 | 1012 |
self.AddBlock(contact) |
27 | 1013 |
self.Controler.AddCurrentElementEditingContact(id) |
1014 |
self.RefreshContactModel(contact) |
|
42 | 1015 |
self.RefreshScrollBars() |
27 | 1016 |
self.Refresh() |
1017 |
dialog.Destroy() |
|
1018 |
||
1019 |
def AddNewCoil(self, bbox): |
|
1020 |
dialog = LDElementDialog(self.Parent, "coil") |
|
1021 |
varlist = [] |
|
1022 |
vars = self.Controler.GetCurrentElementEditingInterfaceVars() |
|
1023 |
if vars: |
|
1024 |
for var in vars: |
|
1025 |
if var["Class"] != "Input" and var["Type"] == "BOOL": |
|
1026 |
varlist.append(var["Name"]) |
|
1027 |
returntype = self.Controler.GetCurrentElementEditingInterfaceReturnType() |
|
1028 |
if returntype == "BOOL": |
|
1029 |
varlist.append(self.Controler.GetCurrentElementEditingName()) |
|
1030 |
dialog.SetVariables(varlist) |
|
1031 |
dialog.SetValues({"name":"","type":COIL_NORMAL}) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1032 |
dialog.SetElementSize((bbox.width, bbox.height)) |
27 | 1033 |
if dialog.ShowModal() == wxID_OK: |
1034 |
id = self.GetNewId() |
|
1035 |
values = dialog.GetValues() |
|
1036 |
coil = LD_Coil(self, values["type"], values["name"], id) |
|
1037 |
coil.SetPosition(bbox.x, bbox.y) |
|
1038 |
coil.SetSize(values["width"], values["height"]) |
|
42 | 1039 |
self.AddBlock(coil) |
27 | 1040 |
self.Controler.AddCurrentElementEditingCoil(id) |
1041 |
self.RefreshCoilModel(contact) |
|
42 | 1042 |
self.RefreshScrollBars() |
27 | 1043 |
self.Refresh() |
1044 |
dialog.Destroy() |
|
1045 |
||
1046 |
def AddNewPowerRail(self, bbox): |
|
1047 |
dialog = LDPowerRailDialog(self.Parent) |
|
1048 |
dialog.SetMinSize((bbox.width, bbox.height)) |
|
1049 |
if dialog.ShowModal() == wxID_OK: |
|
1050 |
id = self.GetNewId() |
|
1051 |
values = dialog.GetValues() |
|
1052 |
powerrail = LD_PowerRail(self, values["type"], id, [True for i in xrange(values["number"])]) |
|
1053 |
powerrail.SetPosition(bbox.x, bbox.y) |
|
1054 |
powerrail.SetSize(values["width"], values["height"]) |
|
42 | 1055 |
self.AddBlock(powerrail) |
27 | 1056 |
self.Controler.AddCurrentElementEditingPowerRail(id, values["type"]) |
1057 |
self.RefreshPowerRailModel(powerrail) |
|
42 | 1058 |
self.RefreshScrollBars() |
27 | 1059 |
self.Refresh() |
1060 |
dialog.Destroy() |
|
1061 |
||
1062 |
def AddNewTransition(self, bbox): |
|
1063 |
dialog = TransitionContentDialog(self.Parent) |
|
1064 |
dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions()) |
|
1065 |
if dialog.ShowModal() == wxID_OK: |
|
1066 |
id = self.GetNewId() |
|
1067 |
values = dialog.GetValues() |
|
1068 |
transition = SFC_Transition(self, values["type"], values["value"], id) |
|
1069 |
transition.SetPosition(bbox.x, bbox.y) |
|
1070 |
min_width, min_height = transition.GetMinSize() |
|
1071 |
transition.SetSize(max(bbox.width, min_width), max(bbox.height, min_height)) |
|
42 | 1072 |
self.AddBlock(transition) |
27 | 1073 |
self.Controler.AddCurrentElementEditingTransition(id) |
1074 |
self.RefreshTransitionModel(transition) |
|
42 | 1075 |
self.RefreshScrollBars() |
27 | 1076 |
self.Refresh() |
1077 |
dialog.Destroy() |
|
1078 |
||
1079 |
def AddNewDivergence(self, bbox): |
|
1080 |
dialog = DivergenceCreateDialog(self.Parent) |
|
1081 |
dialog.SetMinSize((bbox.width, bbox.height)) |
|
1082 |
if dialog.ShowModal() == wxID_OK: |
|
1083 |
id = self.GetNewId() |
|
1084 |
values = dialog.GetValues() |
|
1085 |
divergence = SFC_Divergence(self, values["type"], values["number"], id) |
|
1086 |
divergence.SetPosition(bbox.x, bbox.y) |
|
1087 |
min_width, min_height = divergence.GetMinSize() |
|
1088 |
divergence.SetSize(max(bbox.width, min_width), max(bbox.height, min_height)) |
|
42 | 1089 |
self.AddBlock(divergence) |
27 | 1090 |
self.Controler.AddCurrentElementEditingDivergence(id, values["type"]) |
1091 |
self.RefreshDivergenceModel(divergence) |
|
42 | 1092 |
self.RefreshScrollBars() |
27 | 1093 |
self.Refresh() |
1094 |
dialog.Destroy() |
|
0 | 1095 |
|
27 | 1096 |
|
1097 |
#------------------------------------------------------------------------------- |
|
1098 |
# Edit element content functions |
|
1099 |
#------------------------------------------------------------------------------- |
|
1100 |
||
1101 |
def EditBlockContent(self, block): |
|
1102 |
dialog = BlockPropertiesDialog(self.Parent) |
|
1103 |
dialog.SetBlockList(self.Controler.GetBlockTypes()) |
|
1104 |
dialog.SetMinBlockSize(block.GetSize()) |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1105 |
values = {"name" : block.GetName(), "type" : block.GetType(), "inputs" : block.GetInputTypes()} |
27 | 1106 |
values["extension"] = block.GetExtension() |
1107 |
dialog.SetValues(values) |
|
1108 |
if dialog.ShowModal() == wxID_OK: |
|
1109 |
values = dialog.GetValues() |
|
1110 |
if "name" in values: |
|
1111 |
block.SetName(values["name"]) |
|
1112 |
block.SetSize(values["width"], values["height"]) |
|
1113 |
block.SetType(values["type"], values["extension"]) |
|
1114 |
self.RefreshBlockModel(block) |
|
42 | 1115 |
self.RefreshScrollBars() |
27 | 1116 |
self.Refresh() |
1117 |
dialog.Destroy() |
|
1118 |
||
1119 |
def EditVariableContent(self, variable): |
|
1120 |
dialog = VariablePropertiesDialog(self.Parent) |
|
1121 |
dialog.SetMinVariableSize(variable.GetSize()) |
|
1122 |
varlist = [] |
|
1123 |
vars = self.Controler.GetCurrentElementEditingInterfaceVars() |
|
1124 |
if vars: |
|
1125 |
for var in vars: |
|
1126 |
varlist.append((var["Name"], var["Class"], var["Type"])) |
|
1127 |
returntype = self.Controler.GetCurrentElementEditingInterfaceReturnType() |
|
1128 |
if returntype: |
|
1129 |
varlist.append((self.Controler.GetCurrentElementEditingName(), "Output", returntype)) |
|
1130 |
dialog.SetVariables(varlist) |
|
1131 |
values = {"name" : variable.GetName(), "type" : variable.GetType()} |
|
1132 |
dialog.SetValues(values) |
|
1133 |
if dialog.ShowModal() == wxID_OK: |
|
1134 |
old_type = variable.GetType() |
|
1135 |
values = dialog.GetValues() |
|
1136 |
variable.SetName(values["name"]) |
|
1137 |
variable.SetType(values["type"], values["value_type"]) |
|
1138 |
variable.SetSize(values["width"], values["height"]) |
|
1139 |
if old_type != values["type"]: |
|
1140 |
id = variable.GetId() |
|
1141 |
self.Controler.RemoveCurrentElementEditingInstance(id) |
|
1142 |
self.Controler.AddCurrentElementEditingVariable(id, values["type"]) |
|
1143 |
self.RefreshVariableModel(variable) |
|
42 | 1144 |
self.RefreshScrollBars() |
27 | 1145 |
self.Refresh() |
1146 |
dialog.Destroy() |
|
1147 |
||
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1148 |
def EditConnectionContent(self, connection): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1149 |
dialog = ConnectionPropertiesDialog(self.Parent) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1150 |
dialog.SetMinConnectionSize(connection.GetSize()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1151 |
values = {"name" : connection.GetName(), "type" : connection.GetType()} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1152 |
dialog.SetValues(values) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1153 |
if dialog.ShowModal() == wxID_OK: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1154 |
old_type = connection.GetType() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1155 |
values = dialog.GetValues() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1156 |
connection.SetName(values["name"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1157 |
connection.SetType(values["type"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1158 |
connection.SetSize(values["width"], values["height"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1159 |
if old_type != values["type"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1160 |
id = connection.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1161 |
self.Controler.RemoveCurrentElementEditingInstance(id) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1162 |
self.Controler.AddCurrentElementEditingConnection(id, values["type"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1163 |
self.RefreshConnectionModel(connection) |
42 | 1164 |
self.RefreshScrollBars() |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1165 |
self.Refresh() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1166 |
dialog.Destroy() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1167 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1168 |
def EditContactContent(self, contact): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1169 |
dialog = LDElementDialog(self.Parent, "contact") |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1170 |
varlist = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1171 |
vars = self.Controler.GetCurrentElementEditingInterfaceVars() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1172 |
if vars: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1173 |
for var in vars: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1174 |
if var["Class"] != "Output" and var["Type"] == "BOOL": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1175 |
varlist.append(var["Name"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1176 |
dialog.SetVariables(varlist) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1177 |
values = {"name" : contact.GetName(), "type" : contact.GetType()} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1178 |
dialog.SetValues(values) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1179 |
dialog.SetElementSize(contact.GetSize()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1180 |
if dialog.ShowModal() == wxID_OK: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1181 |
values = dialog.GetValues() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1182 |
contact.SetName(values["name"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1183 |
contact.SetType(values["type"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1184 |
contact.SetSize(values["width"], values["height"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1185 |
self.RefreshContactModel(contact) |
42 | 1186 |
self.RefreshScrollBars() |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1187 |
self.Refresh() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1188 |
dialog.Destroy() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1189 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1190 |
def EditCoilContent(self, coil): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1191 |
dialog = LDElementDialog(self.Parent, "coil") |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1192 |
varlist = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1193 |
vars = self.Controler.GetCurrentElementEditingInterfaceVars() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1194 |
if vars: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1195 |
for var in vars: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1196 |
if var["Class"] != "Input" and var["Type"] == "BOOL": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1197 |
varlist.append(var["Name"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1198 |
returntype = self.Controler.GetCurrentElementEditingInterfaceReturnType() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1199 |
if returntype == "BOOL": |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1200 |
varlist.append(self.Controler.GetCurrentElementEditingName()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1201 |
dialog.SetVariables(varlist) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1202 |
values = {"name" : coil.GetName(), "type" : coil.GetType()} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1203 |
dialog.SetValues(values) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1204 |
dialog.SetElementSize(contact.GetSize()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1205 |
if dialog.ShowModal() == wxID_OK: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1206 |
values = dialog.GetValues() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1207 |
coil.SetName(values["name"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1208 |
coil.SetType(values["type"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1209 |
coil.SetSize(values["width"], values["height"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1210 |
self.RefreshContactModel(coil) |
42 | 1211 |
self.RefreshScrollBars() |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1212 |
self.Refresh() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1213 |
dialog.Destroy() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1214 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1215 |
def EditPowerRailContent(self, powerrail): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1216 |
dialog = LDPowerRailDialog(self.Parent, powerrail.GetType(), len(powerrail.GetConnectors())) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1217 |
dialog.SetMinSize(powerrail.GetSize()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1218 |
if dialog.ShowModal() == wxID_OK: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1219 |
old_type = powerrail.GetType() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1220 |
values = dialog.GetValues() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1221 |
powerrail.SetType(values["type"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1222 |
powerrail.SetSize(values["width"], values["height"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1223 |
if old_type != values["type"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1224 |
id = powerrail.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1225 |
self.Controler.RemoveCurrentElementEditingInstance(id) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1226 |
self.Controler.AddCurrentElementEditingPowerRail(id, values["type"]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1227 |
self.RefreshPowerRailModel(powerrail) |
42 | 1228 |
self.RefreshScrollBars() |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1229 |
self.Refresh() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1230 |
dialog.Destroy() |
42 | 1231 |
## |
1232 |
## |
|
1233 |
## def AddNewTransition(self, bbox): |
|
1234 |
## dialog = TransitionContentDialog(self.Parent) |
|
1235 |
## dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions()) |
|
1236 |
## if dialog.ShowModal() == wxID_OK: |
|
1237 |
## id = self.GetNewId() |
|
1238 |
## values = dialog.GetValues() |
|
1239 |
## transition = SFC_Transition(self, values["type"], values["value"], id) |
|
1240 |
## transition.SetPosition(bbox.x, bbox.y) |
|
1241 |
## min_width, min_height = transition.GetMinSize() |
|
1242 |
## transition.SetSize(max(bbox.width, min_width), max(bbox.height, min_height)) |
|
1243 |
## self.Blocks.append(transition) |
|
1244 |
## self.Elements.append(transition) |
|
1245 |
## self.Controler.AddCurrentElementEditingTransition(id) |
|
1246 |
## self.RefreshTransitionModel(transition) |
|
1247 |
## self.RefreshScrollBars() |
|
1248 |
## self.Refresh() |
|
1249 |
## dialog.Destroy() |
|
1250 |
## |
|
1251 |
## def AddNewDivergence(self, bbox): |
|
1252 |
## dialog = DivergenceCreateDialog(self.Parent) |
|
1253 |
## dialog.SetMinSize((bbox.width, bbox.height)) |
|
1254 |
## if dialog.ShowModal() == wxID_OK: |
|
1255 |
## id = self.GetNewId() |
|
1256 |
## values = dialog.GetValues() |
|
1257 |
## divergence = SFC_Divergence(self, values["type"], values["number"], id) |
|
1258 |
## divergence.SetPosition(bbox.x, bbox.y) |
|
1259 |
## min_width, min_height = divergence.GetMinSize() |
|
1260 |
## divergence.SetSize(max(bbox.width, min_width), max(bbox.height, min_height)) |
|
1261 |
## self.Blocks.append(divergence) |
|
1262 |
## self.Elements.append(divergence) |
|
1263 |
## self.Controler.AddCurrentElementEditingDivergence(id, values["type"]) |
|
1264 |
## self.RefreshDivergenceModel(divergence) |
|
1265 |
## self.RefreshScrollBars() |
|
1266 |
## self.Refresh() |
|
1267 |
## dialog.Destroy() |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1268 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1269 |
#------------------------------------------------------------------------------- |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1270 |
# Model update functions |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1271 |
#------------------------------------------------------------------------------- |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1272 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1273 |
def RefreshBlockModel(self, block): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1274 |
blockid = block.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1275 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1276 |
infos["type"] = block.GetType() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1277 |
infos["name"] = block.GetName() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1278 |
infos["x"], infos["y"] = block.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1279 |
infos["width"], infos["height"] = block.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1280 |
infos["connectors"] = block.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1281 |
self.Controler.SetCurrentElementEditingBlockInfos(blockid, infos) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1282 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1283 |
def RefreshVariableModel(self, variable): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1284 |
variableid = variable.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1285 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1286 |
infos["name"] = variable.GetName() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1287 |
infos["x"], infos["y"] = variable.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1288 |
infos["width"], infos["height"] = variable.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1289 |
infos["connectors"] = variable.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1290 |
self.Controler.SetCurrentElementEditingVariableInfos(variableid, infos) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1291 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1292 |
def RefreshConnectionModel(self, connection): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1293 |
connectionid = connection.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1294 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1295 |
infos["name"] = connection.GetName() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1296 |
infos["x"], infos["y"] = connection.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1297 |
infos["width"], infos["height"] = connection.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1298 |
infos["connector"] = connection.GetConnector() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1299 |
self.Controler.SetCurrentElementEditingConnectionInfos(connectionid, infos) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1300 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1301 |
def RefreshCommentModel(self, comment): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1302 |
commentid = comment.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1303 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1304 |
infos["content"] = comment.GetContent() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1305 |
infos["x"], infos["y"] = comment.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1306 |
infos["width"], infos["height"] = comment.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1307 |
self.Controler.SetCurrentElementEditingCommentInfos(commentid, infos) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1308 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1309 |
def RefreshPowerRailModel(self, powerrail): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1310 |
powerrailid = powerrail.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1311 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1312 |
infos["x"], infos["y"] = powerrail.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1313 |
infos["width"], infos["height"] = powerrail.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1314 |
infos["connectors"] = powerrail.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1315 |
self.Controler.SetCurrentElementEditingPowerRailInfos(powerrailid, infos) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1316 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1317 |
def RefreshContactModel(self, contact): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1318 |
contactid = contact.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1319 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1320 |
infos["name"] = contact.GetName() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1321 |
infos["type"] = contact.GetType() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1322 |
infos["x"], infos["y"] = contact.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1323 |
infos["width"], infos["height"] = contact.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1324 |
infos["connectors"] = contact.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1325 |
self.Controler.SetCurrentElementEditingContactInfos(contactid, infos) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1326 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1327 |
def RefreshCoilModel(self, coil): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1328 |
coilid = coil.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1329 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1330 |
infos["name"] = coil.GetName() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1331 |
infos["type"] = coil.GetType() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1332 |
infos["x"], infos["y"] = coil.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1333 |
infos["width"], infos["height"] = coil.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1334 |
infos["connectors"] = coil.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1335 |
self.Controler.SetCurrentElementEditingCoilInfos(coilid, infos) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1336 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1337 |
def RefreshStepModel(self, step): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1338 |
stepid = step.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1339 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1340 |
infos["name"] = step.GetName() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1341 |
infos["initial"] = step.GetInitial() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1342 |
infos["x"], infos["y"] = step.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1343 |
infos["width"], infos["height"] = step.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1344 |
infos["connectors"] = step.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1345 |
self.Controler.SetCurrentElementEditingStepInfos(stepid, infos) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1346 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1347 |
def RefreshTransitionModel(self, transition): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1348 |
transitionid = transition.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1349 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1350 |
infos["type"] = transition.GetType() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1351 |
infos["condition"] = transition.GetCondition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1352 |
infos["x"], infos["y"] = transition.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1353 |
infos["width"], infos["height"] = transition.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1354 |
infos["connectors"] = transition.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1355 |
self.Controler.SetCurrentElementEditingTransitionInfos(transitionid, infos) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1356 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1357 |
def RefreshDivergenceModel(self, divergence): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1358 |
divergenceid = divergence.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1359 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1360 |
infos["x"], infos["y"] = divergence.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1361 |
infos["width"], infos["height"] = divergence.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1362 |
infos["connectors"] = divergence.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1363 |
self.Controler.SetCurrentElementEditingDivergenceInfos(divergenceid, infos) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1364 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1365 |
def RefreshJumpModel(self, jump): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1366 |
jumpid = jump.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1367 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1368 |
infos["target"] = jump.GetTarget() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1369 |
infos["x"], infos["y"] = jump.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1370 |
infos["width"], infos["height"] = jump.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1371 |
infos["connector"] = jump.GetConnector() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1372 |
self.Controler.SetCurrentElementEditingJumpInfos(jumpid, infos) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1373 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1374 |
def RefreshActionBlockModel(self, actionblock): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1375 |
actionblockid = actionblock.GetId() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1376 |
infos = {} |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1377 |
infos["actions"] = actionblock.GetActions() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1378 |
infos["x"], infos["y"] = actionblock.GetPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1379 |
infos["width"], infos["height"] = actionblock.GetSize() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1380 |
infos["connector"] = actionblock.GetConnector() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1381 |
self.Controler.SetCurrentElementEditingActionBlockInfos(actionblockid, infos) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1382 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1383 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1384 |
#------------------------------------------------------------------------------- |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1385 |
# Model delete functions |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1386 |
#------------------------------------------------------------------------------- |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1387 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1388 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1389 |
def DeleteBlock(self, block): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1390 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1391 |
for output in block.GetConnectors()["outputs"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1392 |
for element in output.GetConnectedBlocks(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1393 |
if element not in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1394 |
elements.append(element) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1395 |
block.Clean() |
42 | 1396 |
self.RemoveBlock(block) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1397 |
self.Controler.RemoveCurrentElementEditingInstance(block.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1398 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1399 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1400 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1401 |
def DeleteVariable(self, variable): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1402 |
connectors = variable.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1403 |
if connectors["output"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1404 |
elements = connectors["output"].GetConnectedBlocks() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1405 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1406 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1407 |
variable.Clean() |
42 | 1408 |
self.RemoveBlock(variable) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1409 |
self.Controler.RemoveCurrentElementEditingInstance(variable.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1410 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1411 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1412 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1413 |
def DeleteConnection(self, connection): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1414 |
if connection.GetType() == CONTINUATION: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1415 |
elements = connection.GetConnector().GetConnectedBlocks() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1416 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1417 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1418 |
connection.Clean() |
42 | 1419 |
self.RemoveBlock(connection) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1420 |
self.Controler.RemoveCurrentElementEditingInstance(connection.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1421 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1422 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1423 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1424 |
def DeleteComment(self, comment): |
42 | 1425 |
self.RemoveComment(comment) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1426 |
self.Controler.RemoveCurrentElementEditingInstance(comment.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1427 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1428 |
def DeleteWire(self, wire): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1429 |
if wire in self.Wires: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1430 |
connected = wire.GetConnected() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1431 |
wire.Clean() |
42 | 1432 |
self.RemoveWire(wire) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1433 |
for connector in connected: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1434 |
connector.RefreshParentBlock() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1435 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1436 |
def DeleteContact(self, contact): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1437 |
connectors = contact.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1438 |
elements = connectors["output"].GetConnectedBlocks() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1439 |
contact.Clean() |
42 | 1440 |
self.RemoveBlock(contact) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1441 |
self.Controler.RemoveCurrentElementEditingInstance(contact.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1442 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1443 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1444 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1445 |
def DeleteCoil(self, coil): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1446 |
connectors = coil.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1447 |
elements = connectors["output"].GetConnectedBlocks() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1448 |
coil.Clean() |
42 | 1449 |
self.RemoveBlock(coil) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1450 |
self.Controler.RemoveCurrentElementEditingInstance(coil.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1451 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1452 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1453 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1454 |
def DeletePowerRail(self, powerrail): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1455 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1456 |
if powerrail.GetType() == LEFTRAIL: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1457 |
for connector in powerrail.GetConnectors(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1458 |
for element in connector.GetConnectedBlocks(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1459 |
if element not in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1460 |
elements.append(element) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1461 |
powerrrail.Clean() |
42 | 1462 |
self.RemoveBlock(powerrrail) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1463 |
self.Controler.RemoveCurrentElementEditingInstance(powerrrail.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1464 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1465 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1466 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1467 |
def DeleteStep(self, step): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1468 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1469 |
connectors = step.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1470 |
if connectors["output"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1471 |
for element in connectors["output"].GetConnectedBlocks(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1472 |
if element not in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1473 |
elements.append(element) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1474 |
if connectors["action"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1475 |
for element in connectors["action"].GetConnectedBlocks(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1476 |
if element not in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1477 |
elements.append(element) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1478 |
step.Clean() |
42 | 1479 |
self.RemoveBlock(step) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1480 |
self.Controler.RemoveCurrentElementEditingInstance(step.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1481 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1482 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1483 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1484 |
def DeleteTransition(self, transition): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1485 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1486 |
connectors = transition.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1487 |
if connectors["output"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1488 |
for element in connectors["output"].GetConnectedBlocks(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1489 |
if element not in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1490 |
elements.append(element) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1491 |
transition.Clean() |
42 | 1492 |
self.RemoveBlock(transition) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1493 |
self.Controler.RemoveCurrentElementEditingInstance(transition.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1494 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1495 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1496 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1497 |
def DeleteDivergence(self, divergence): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1498 |
elements = [] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1499 |
connectors = divergence.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1500 |
for output in connectors["outputs"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1501 |
for element in output.GetConnectedBlocks(): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1502 |
if element not in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1503 |
elements.append(element) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1504 |
divergence.Clean() |
42 | 1505 |
self.RemoveBlock(divergence) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1506 |
self.Controler.RemoveCurrentElementEditingInstance(divergence.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1507 |
for element in elements: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1508 |
element.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1509 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1510 |
def DeleteJump(self, jump): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1511 |
jump.Clean() |
42 | 1512 |
self.RemoveBlock(jump) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1513 |
self.Controler.RemoveCurrentElementEditingInstance(jump.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1514 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1515 |
def DeleteActionBlock(self, actionblock): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1516 |
actionblock.Clean() |
42 | 1517 |
self.RemoveBlock(actionblock) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1518 |
self.Controler.RemoveCurrentElementEditingInstance(actionblock.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1519 |
|
27 | 1520 |
|
0 | 1521 |
#------------------------------------------------------------------------------- |
1522 |
# Editing functions |
|
1523 |
#------------------------------------------------------------------------------- |
|
1524 |
||
1525 |
def Cut(self): |
|
1526 |
pass |
|
1527 |
||
1528 |
def Copy(self): |
|
1529 |
pass |
|
1530 |
||
1531 |
def Paste(self): |
|
1532 |
pass |
|
1533 |
||
1534 |
#------------------------------------------------------------------------------- |
|
1535 |
# Drawing functions |
|
1536 |
#------------------------------------------------------------------------------- |
|
1537 |
||
27 | 1538 |
def OnMoveWindow(self, event): |
42 | 1539 |
self.RefreshScrollBars() |
27 | 1540 |
event.Skip() |
1541 |
||
0 | 1542 |
def OnPaint(self, event): |
27 | 1543 |
dc = self.GetLogicalDC() |
0 | 1544 |
dc.Clear() |
1545 |
dc.SetPen(wxPen(wxColour(230, 230, 230))) |
|
1546 |
if self.Scaling and self.DrawGrid: |
|
1547 |
width, height = dc.GetSize() |
|
1548 |
for i in xrange(1, width / self.Scaling[0] + 1): |
|
1549 |
dc.DrawLine(i * self.Scaling[0], 0, i * self.Scaling[0], height) |
|
1550 |
for i in xrange(1, height / self.Scaling[1] + 1): |
|
1551 |
dc.DrawLine(0, i * self.Scaling[1], width, i * self.Scaling[1]) |
|
42 | 1552 |
for comment in self.Comments: |
1553 |
if comment != self.SelectedElement: |
|
1554 |
comment.Draw(dc) |
|
0 | 1555 |
for wire in self.Wires: |
1556 |
if wire != self.SelectedElement: |
|
1557 |
wire.Draw(dc) |
|
42 | 1558 |
for block in self.Blocks: |
1559 |
if block != self.SelectedElement: |
|
1560 |
block.Draw(dc) |
|
0 | 1561 |
if self.SelectedElement: |
1562 |
self.SelectedElement.Draw(dc) |
|
27 | 1563 |
if self.rubberBand.IsShown(): |
1564 |
self.rubberBand.Draw() |
|
1565 |
event.Skip() |
|
1566 |
||
1567 |