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