author | lbessard |
Wed, 18 Jul 2007 16:22:39 +0200 | |
changeset 44 | c6e153273ea1 |
parent 42 | 4a8400732001 |
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 |
from types import * |
|
28 |
||
29 |
from plcopen.structures import * |
|
30 |
from graphics.GraphicCommons import * |
|
31 |
from graphics.SFC_Objects import * |
|
32 |
from Viewer import * |
|
27 | 33 |
from Dialogs import * |
0 | 34 |
|
35 |
class SFC_Viewer(Viewer): |
|
36 |
||
37 |
def __init__(self, parent, window, controler): |
|
38 |
Viewer.__init__(self, parent, window, controler) |
|
39 |
||
40 |
def ConnectConnectors(self, start, end): |
|
41 |
startpoint = [start.GetPosition(False), start.GetDirection()] |
|
42 |
endpoint = [end.GetPosition(False), end.GetDirection()] |
|
43 |
wire = Wire(self, startpoint, endpoint) |
|
42 | 44 |
self.AddWire(wire) |
0 | 45 |
start.Connect((wire, 0), False) |
46 |
end.Connect((wire, -1), False) |
|
47 |
wire.ConnectStartPoint(None, start) |
|
48 |
wire.ConnectEndPoint(None, end) |
|
49 |
return wire |
|
50 |
||
51 |
def CreateTransition(self, connector, next = None): |
|
52 |
previous = connector.GetParentBlock() |
|
53 |
id = self.GetNewId() |
|
54 |
transition = SFC_Transition(self, "reference", "", id) |
|
55 |
pos = connector.GetPosition(False) |
|
56 |
transition.SetPosition(pos.x, pos.y + SFC_WIRE_MIN_SIZE) |
|
57 |
transition_connectors = transition.GetConnectors() |
|
58 |
wire = self.ConnectConnectors(transition_connectors["input"], connector) |
|
59 |
if isinstance(previous, SFC_Divergence): |
|
60 |
previous.RefreshConnectedPosition(connector) |
|
61 |
else: |
|
62 |
previous.RefreshOutputPosition() |
|
63 |
wire.SetPoints([wxPoint(pos.x, pos.y + GetWireSize(previous)), wxPoint(pos.x, pos.y)]) |
|
42 | 64 |
self.AddBlock(transition) |
0 | 65 |
self.Controler.AddCurrentElementEditingTransition(id) |
66 |
self.RefreshTransitionModel(transition) |
|
67 |
if next: |
|
68 |
wire = self.ConnectConnectors(next, transition_connectors["output"]) |
|
69 |
pos = transition_connectors["output"].GetPosition(False) |
|
70 |
next_block = next.GetParentBlock() |
|
71 |
next_pos = next.GetPosition(False) |
|
72 |
transition.RefreshOutputPosition((0, pos.y + SFC_WIRE_MIN_SIZE - next_pos.y)) |
|
73 |
wire.SetPoints([wxPoint(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wxPoint(pos.x, pos.y)]) |
|
74 |
if isinstance(next_block, SFC_Divergence): |
|
75 |
next_block.RefreshPosition() |
|
2 | 76 |
transition.RefreshOutputModel(True) |
0 | 77 |
return transition |
78 |
||
79 |
def RemoveTransition(self, transition): |
|
80 |
connectors = transition.GetConnectors() |
|
81 |
input_wires = connectors["input"].GetWires() |
|
82 |
if len(input_wires) != 1: |
|
83 |
return |
|
84 |
input_wire = input_wires[0][0] |
|
85 |
previous = input_wire.EndConnected |
|
86 |
input_wire.Clean() |
|
42 | 87 |
self.RemoveWire(input_wire) |
0 | 88 |
output_wires = connectors["output"].GetWires() |
89 |
if len(output_wires) != 1: |
|
90 |
return |
|
91 |
output_wire = output_wires[0][0] |
|
92 |
next = output_wire.StartConnected |
|
93 |
output_wire.Clean() |
|
42 | 94 |
self.RemoveWire(output_wire) |
0 | 95 |
transition.Clean() |
42 | 96 |
self.RemoveBlock(transition) |
0 | 97 |
self.Controler.RemoveCurrentElementEditingInstance(transition.GetId()) |
98 |
wire = self.ConnectConnectors(next, previous) |
|
99 |
return wire |
|
100 |
||
101 |
def CreateStep(self, name, connector, next = None): |
|
102 |
previous = connector.GetParentBlock() |
|
103 |
id = self.GetNewId() |
|
104 |
step = SFC_Step(self, name, False, id) |
|
105 |
if next: |
|
106 |
step.AddOutput() |
|
107 |
min_width, min_height = step.GetMinSize() |
|
108 |
pos = connector.GetPosition(False) |
|
109 |
step.SetPosition(pos.x, pos.y + SFC_WIRE_MIN_SIZE) |
|
110 |
step.SetSize(min_width, min_height) |
|
111 |
step_connectors = step.GetConnectors() |
|
112 |
wire = self.ConnectConnectors(step_connectors["input"], connector) |
|
113 |
if isinstance(previous, SFC_Divergence): |
|
114 |
previous.RefreshConnectedPosition(connector) |
|
115 |
else: |
|
116 |
previous.RefreshOutputPosition() |
|
117 |
wire.SetPoints([wxPoint(pos.x, pos.y + GetWireSize(previous)), wxPoint(pos.x, pos.y)]) |
|
42 | 118 |
self.AddBlock(step) |
0 | 119 |
self.Controler.AddCurrentElementEditingStep(id) |
120 |
self.RefreshStepModel(step) |
|
121 |
if next: |
|
122 |
wire = self.ConnectConnectors(next, step_connectors["output"]) |
|
123 |
pos = step_connectors["output"].GetPosition(False) |
|
124 |
next_block = next.GetParentBlock() |
|
125 |
next_pos = next.GetPosition(False) |
|
126 |
step.RefreshOutputPosition((0, pos.y + SFC_WIRE_MIN_SIZE - next_pos.y)) |
|
127 |
wire.SetPoints([wxPoint(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wxPoint(pos.x, pos.y)]) |
|
128 |
if isinstance(next_block, SFC_Divergence): |
|
129 |
next_block.RefreshPosition() |
|
2 | 130 |
step.RefreshOutputModel(True) |
0 | 131 |
return step |
132 |
||
133 |
def RemoveStep(self, step): |
|
134 |
connectors = step.GetConnectors() |
|
135 |
if connectors["input"]: |
|
136 |
input_wires = connectors["input"].GetWires() |
|
137 |
if len(input_wires) != 1: |
|
138 |
return |
|
139 |
input_wire = input_wires[0][0] |
|
140 |
previous = input_wire.EndConnected |
|
141 |
input_wire.Clean() |
|
42 | 142 |
self.RemoveWire(input_wire) |
0 | 143 |
else: |
144 |
previous = None |
|
145 |
if connectors["output"]: |
|
146 |
output_wires = connectors["output"].GetWires() |
|
147 |
if len(output_wires) != 1: |
|
148 |
return |
|
149 |
output_wire = output_wires[0][0] |
|
150 |
next = output_wire.StartConnected |
|
151 |
output_wire.Clean() |
|
42 | 152 |
self.RemoveWire(output_wire) |
0 | 153 |
else: |
154 |
next = None |
|
155 |
action = step.GetActionConnector() |
|
156 |
if action: |
|
157 |
self.DeleteActionBlock(action.GetParentBlock()) |
|
158 |
step.Clean() |
|
42 | 159 |
self.RemoveBlock(step) |
0 | 160 |
self.Controler.RemoveCurrentElementEditingInstance(step.GetId()) |
161 |
if next and previous: |
|
162 |
wire = self.ConnectConnectors(next, previous) |
|
163 |
return wire |
|
164 |
else: |
|
165 |
return None |
|
166 |
||
167 |
#------------------------------------------------------------------------------- |
|
168 |
# Mouse event functions |
|
169 |
#------------------------------------------------------------------------------- |
|
170 |
||
171 |
def OnViewerLeftDown(self, event): |
|
27 | 172 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
173 |
Viewer.OnViewerLeftDown(self, event) |
|
174 |
elif self.Mode == MODE_SELECTION: |
|
175 |
dc = self.GetLogicalDC() |
|
176 |
pos = event.GetLogicalPosition(dc) |
|
0 | 177 |
if event.ControlDown(): |
178 |
element = self.FindElement(pos, True) |
|
42 | 179 |
if element and not self.IsWire(element): |
0 | 180 |
if isinstance(self.SelectedElement, Graphic_Group): |
181 |
self.SelectedElement.SelectElement(element) |
|
182 |
else: |
|
183 |
group = Graphic_Group(self) |
|
184 |
self.SelectedElement.SetSelected(False) |
|
185 |
group.SelectElement(self.SelectedElement) |
|
186 |
group.SelectElement(element) |
|
187 |
self.SelectedElement = group |
|
188 |
elements = self.SelectedElement.GetElements() |
|
189 |
if len(elements) == 0: |
|
190 |
self.SelectedElement = element |
|
191 |
elif len(elements) == 1: |
|
192 |
self.SelectedElement = elements[0] |
|
193 |
else: |
|
194 |
element = self.FindElement(pos) |
|
195 |
if self.SelectedElement and self.SelectedElement != element: |
|
42 | 196 |
if self.IsWire(self.SelectedElement): |
0 | 197 |
self.SelectedElement.SetSelectedSegment(None) |
198 |
else: |
|
199 |
self.SelectedElement.SetSelected(False) |
|
200 |
self.SelectedElement = None |
|
201 |
self.Refresh() |
|
202 |
if element: |
|
203 |
self.SelectedElement = element |
|
27 | 204 |
self.SelectedElement.OnLeftDown(event, dc, self.Scaling) |
0 | 205 |
self.Refresh() |
206 |
else: |
|
207 |
self.rubberBand.Reset() |
|
27 | 208 |
self.rubberBand.OnLeftDown(event, dc, self.Scaling) |
0 | 209 |
elif self.Mode == MODE_COMMENT: |
210 |
self.rubberBand.Reset() |
|
27 | 211 |
self.rubberBand.OnLeftDown(event, self.GetLogicalDC(), self.Scaling) |
0 | 212 |
elif self.Mode == MODE_WIRE: |
27 | 213 |
pos = GetScaledEventPosition(event, self.GetLogicalDC(), self.Scaling) |
0 | 214 |
wire = Wire(self, [wxPoint(pos.x, pos.y), SOUTH], [wxPoint(pos.x, pos.y), NORTH]) |
215 |
wire.oldPos = pos |
|
216 |
wire.Handle = (HANDLE_POINT, 0) |
|
217 |
wire.ProcessDragging(0, 0) |
|
218 |
wire.Handle = (HANDLE_POINT, 1) |
|
42 | 219 |
self.AddWire(wire) |
0 | 220 |
if self.SelectedElement: |
221 |
self.SelectedElement.SetSelected(False) |
|
222 |
self.SelectedElement = wire |
|
223 |
self.Refresh() |
|
224 |
event.Skip() |
|
225 |
||
226 |
def OnViewerLeftUp(self, event): |
|
27 | 227 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
228 |
Viewer.OnViewerLeftUp(self, event) |
|
229 |
elif self.rubberBand.IsShown(): |
|
0 | 230 |
if self.Mode == MODE_SELECTION: |
231 |
elements = self.SearchElements(self.rubberBand.GetCurrentExtent()) |
|
27 | 232 |
self.rubberBand.OnLeftUp(event, self.GetLogicalDC(), self.Scaling) |
0 | 233 |
if len(elements) > 0: |
234 |
self.SelectedElement = Graphic_Group(self) |
|
235 |
self.SelectedElement.SetElements(elements) |
|
236 |
self.SelectedElement.SetSelected(True) |
|
237 |
self.Refresh() |
|
238 |
elif self.Mode == MODE_COMMENT: |
|
239 |
bbox = self.rubberBand.GetCurrentExtent() |
|
27 | 240 |
self.rubberBand.OnLeftUp(event, self.GetLogicalDC(), self.Scaling) |
0 | 241 |
wxCallAfter(self.AddComment, bbox) |
27 | 242 |
elif self.Mode == MODE_INITIALSTEP: |
243 |
wxCallAfter(self.AddInitialStep, GetScaledEventPosition(event, self.GetLogicalDC(), self.Scaling)) |
|
0 | 244 |
elif self.Mode == MODE_SELECTION and self.SelectedElement: |
42 | 245 |
if self.IsWire(self.SelectedElement): |
0 | 246 |
self.SelectedElement.SetSelectedSegment(0) |
247 |
else: |
|
27 | 248 |
self.SelectedElement.OnLeftUp(event, self.GetLogicalDC(), self.Scaling) |
0 | 249 |
wxCallAfter(self.SetCursor, wxNullCursor) |
250 |
self.ReleaseMouse() |
|
251 |
self.Refresh() |
|
252 |
elif self.Mode == MODE_WIRE and self.SelectedElement: |
|
253 |
self.SelectedElement.ResetPoints() |
|
27 | 254 |
self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling) |
0 | 255 |
self.SelectedElement.GeneratePoints() |
256 |
self.SelectedElement.RefreshModel() |
|
257 |
self.SelectedElement.SetSelected(True) |
|
258 |
self.Refresh() |
|
259 |
event.Skip() |
|
260 |
||
261 |
def OnViewerRightUp(self, event): |
|
27 | 262 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
263 |
Viewer.OnViewerRightUp(self, event) |
|
264 |
else: |
|
265 |
dc = self.GetLogicalDC() |
|
266 |
pos = event.GetLogicalPosition(dc) |
|
267 |
element = self.FindElement(pos) |
|
268 |
if element: |
|
269 |
if self.SelectedElement and self.SelectedElement != element: |
|
270 |
self.SelectedElement.SetSelected(False) |
|
271 |
self.SelectedElement = element |
|
42 | 272 |
if self.IsWire(self.SelectedElement): |
27 | 273 |
self.SelectedElement.SetSelectedSegment(0) |
274 |
else: |
|
275 |
self.SelectedElement.SetSelected(True) |
|
276 |
self.SelectedElement.OnRightUp(event, dc, self.Scaling) |
|
277 |
wxCallAfter(self.SetCursor, wxNullCursor) |
|
278 |
self.ReleaseMouse() |
|
279 |
self.Refresh() |
|
0 | 280 |
event.Skip() |
281 |
||
282 |
def OnViewerLeftDClick(self, event): |
|
27 | 283 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
284 |
Viewer.OnViewerLeftDClick(self, event) |
|
285 |
elif self.Mode == MODE_SELECTION and self.SelectedElement: |
|
286 |
self.SelectedElement.OnLeftDClick(event, self.GetLogicalDC(), self.Scaling) |
|
0 | 287 |
self.Refresh() |
288 |
event.Skip() |
|
289 |
||
290 |
def OnViewerMotion(self, event): |
|
27 | 291 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
292 |
Viewer.OnViewerMotion(self, event) |
|
293 |
elif self.rubberBand.IsShown(): |
|
294 |
self.rubberBand.OnMotion(event, self.GetLogicalDC(), self.Scaling) |
|
0 | 295 |
elif self.Mode == MODE_SELECTION and self.SelectedElement: |
42 | 296 |
if not self.IsWire(self.SelectedElement): |
27 | 297 |
self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling) |
0 | 298 |
self.Refresh() |
299 |
elif self.Mode == MODE_WIRE and self.SelectedElement: |
|
300 |
self.SelectedElement.ResetPoints() |
|
27 | 301 |
self.SelectedElement.OnMotion(event, self.GetLogicalDC(), self.Scaling) |
0 | 302 |
self.SelectedElement.GeneratePoints() |
303 |
self.Refresh() |
|
27 | 304 |
Viewer.OnViewerMotion(self, event) |
0 | 305 |
event.Skip() |
306 |
||
307 |
#------------------------------------------------------------------------------- |
|
308 |
# Keyboard event functions |
|
309 |
#------------------------------------------------------------------------------- |
|
310 |
||
311 |
def OnChar(self, event): |
|
312 |
keycode = event.GetKeyCode() |
|
313 |
if self.Scaling: |
|
314 |
scaling = self.Scaling |
|
315 |
else: |
|
316 |
scaling = (8, 8) |
|
317 |
if keycode == WXK_DELETE and self.SelectedElement: |
|
318 |
self.SelectedElement.Delete() |
|
319 |
self.SelectedElement = None |
|
42 | 320 |
elif keycode == WXK_LEFT: |
321 |
if event.ControlDown() and event.ShiftDown(): |
|
322 |
self.Scroll(0, ypos) |
|
323 |
elif event.ControlDown(): |
|
324 |
self.Scroll(max(0, xpos - 1), ypos) |
|
325 |
elif self.SelectedElement: |
|
326 |
self.SelectedElement.Move(-scaling[0], 0) |
|
327 |
elif keycode == WXK_RIGHT: |
|
328 |
if event.ControlDown() and event.ShiftDown(): |
|
329 |
self.Scroll(xmax, ypos) |
|
330 |
elif event.ControlDown(): |
|
331 |
self.Scroll(min(xpos + 1, xmax), ypos) |
|
332 |
elif self.SelectedElement: |
|
333 |
self.SelectedElement.Move(scaling[0], 0) |
|
334 |
elif keycode == WXK_UP: |
|
335 |
if event.ControlDown() and event.ShiftDown(): |
|
336 |
self.Scroll(xpos, 0) |
|
337 |
elif event.ControlDown(): |
|
338 |
self.Scroll(xpos, max(0, ypos - 1)) |
|
339 |
elif self.SelectedElement: |
|
340 |
self.SelectedElement.Move(0, -scaling[1]) |
|
341 |
elif keycode == WXK_DOWN: |
|
342 |
if event.ControlDown() and event.ShiftDown(): |
|
343 |
self.Scroll(xpos, ymax) |
|
344 |
elif event.ControlDown(): |
|
345 |
self.Scroll(xpos, min(ypos + 1, ymax)) |
|
346 |
elif self.SelectedElement: |
|
347 |
self.SelectedElement.Move(0, scaling[1]) |
|
0 | 348 |
self.Refresh() |
349 |
||
350 |
#------------------------------------------------------------------------------- |
|
351 |
# Adding element functions |
|
352 |
#------------------------------------------------------------------------------- |
|
353 |
||
354 |
def AddInitialStep(self, pos): |
|
9 | 355 |
dialog = StepNameDialog(self.Parent, "Add a new initial step", "Please enter step name", "", wxOK|wxCANCEL) |
356 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
357 |
dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars()) |
|
358 |
dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)]) |
|
0 | 359 |
if dialog.ShowModal() == wxID_OK: |
360 |
id = self.GetNewId() |
|
361 |
name = dialog.GetValue() |
|
362 |
step = SFC_Step(self, name, True, id) |
|
363 |
min_width, min_height = step.GetMinSize() |
|
364 |
step.SetPosition(pos.x, pos.y) |
|
365 |
width, height = step.GetSize() |
|
366 |
step.SetSize(max(min_width, width), max(min_height, height)) |
|
42 | 367 |
self.AddBlock(step) |
0 | 368 |
self.Controler.AddCurrentElementEditingStep(id) |
369 |
self.RefreshStepModel(step) |
|
370 |
self.Parent.RefreshProjectTree() |
|
371 |
self.Refresh() |
|
372 |
dialog.Destroy() |
|
373 |
||
374 |
def AddStep(self): |
|
375 |
if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, SFC_Step): |
|
9 | 376 |
dialog = StepNameDialog(self.Parent, "Add a new step", "Please enter step name", "", wxOK|wxCANCEL) |
377 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
378 |
dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars()) |
|
379 |
dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step)]) |
|
0 | 380 |
if dialog.ShowModal() == wxID_OK: |
381 |
name = dialog.GetValue() |
|
42 | 382 |
if self.IsWire(self.SelectedElement): |
0 | 383 |
self.SelectedElement.SetSelectedSegment(None) |
384 |
previous = self.SelectedElement.EndConnected |
|
385 |
next = self.SelectedElement.StartConnected |
|
386 |
self.SelectedElement.Clean() |
|
42 | 387 |
self.RemoveWire(self.SelectedElement) |
0 | 388 |
else: |
389 |
connectors = self.SelectedElement.GetConnectors() |
|
390 |
if connectors["output"]: |
|
391 |
previous = connectors["output"] |
|
392 |
wires = previous.GetWires() |
|
393 |
if len(wires) != 1: |
|
394 |
return |
|
395 |
wire = wires[0][0] |
|
396 |
next = wire.StartConnected |
|
397 |
wire.Clean() |
|
42 | 398 |
self.RemoveWire(wire) |
0 | 399 |
else: |
400 |
self.SelectedElement.AddOutput() |
|
401 |
connectors = self.SelectedElement.GetConnectors() |
|
402 |
self.RefreshStepModel(self.SelectedElement) |
|
403 |
previous = connectors["output"] |
|
404 |
next = None |
|
405 |
previous_block = previous.GetParentBlock() |
|
406 |
if isinstance(previous_block, SFC_Step) or isinstance(previous_block, SFC_Divergence) and previous_block.GetType() in [SELECTION_DIVERGENCE, SELECTION_CONVERGENCE]: |
|
407 |
transition = self.CreateTransition(previous) |
|
408 |
transition_connectors = transition.GetConnectors() |
|
409 |
step = self.CreateStep(name, transition_connectors["output"], next) |
|
410 |
else: |
|
411 |
step = self.CreateStep(name, previous) |
|
412 |
step.AddOutput() |
|
413 |
step.RefreshModel() |
|
414 |
step_connectors = step.GetConnectors() |
|
415 |
transition = self.CreateTransition(step_connectors["output"], next) |
|
42 | 416 |
if self.IsWire(self.SelectedElement): |
0 | 417 |
self.SelectedElement = wire |
418 |
self.SelectedElement.SetSelectedSegment(0) |
|
419 |
else: |
|
420 |
self.SelectedElement.SetSelected(False) |
|
421 |
self.SelectedElement = step |
|
422 |
self.SelectedElement.SetSelected(True) |
|
423 |
self.Parent.RefreshProjectTree() |
|
424 |
self.Refresh() |
|
425 |
dialog.Destroy() |
|
426 |
||
427 |
def AddStepAction(self): |
|
428 |
if isinstance(self.SelectedElement, SFC_Step): |
|
429 |
connectors = self.SelectedElement.GetConnectors() |
|
430 |
if not connectors["action"]: |
|
431 |
dialog = ActionBlockDialog(self.Parent) |
|
432 |
dialog.SetQualifierList(self.Controler.GetQualifierTypes()) |
|
433 |
dialog.SetActionList(self.Controler.GetCurrentElementEditingActions()) |
|
434 |
dialog.SetVariableList(self.Controler.GetCurrentElementEditingInterfaceVars()) |
|
435 |
if dialog.ShowModal() == wxID_OK: |
|
436 |
actions = dialog.GetValues() |
|
437 |
self.SelectedElement.AddAction() |
|
438 |
self.RefreshStepModel(self.SelectedElement) |
|
439 |
connectors = self.SelectedElement.GetConnectors() |
|
440 |
pos = connectors["action"].GetPosition(False) |
|
441 |
id = self.GetNewId() |
|
442 |
actionblock = SFC_ActionBlock(self, [], id) |
|
443 |
actionblock.SetPosition(pos.x + SFC_WIRE_MIN_SIZE, pos.y - SFC_STEP_DEFAULT_SIZE[1] / 2) |
|
444 |
actionblock_connector = actionblock.GetConnector() |
|
445 |
wire = self.ConnectConnectors(actionblock_connector, connectors["action"]) |
|
446 |
wire.SetPoints([wxPoint(pos.x + SFC_WIRE_MIN_SIZE, pos.y), wxPoint(pos.x, pos.y)]) |
|
447 |
actionblock.SetActions(actions) |
|
42 | 448 |
self.AddBlock(actionblock) |
0 | 449 |
self.Controler.AddCurrentElementEditingActionBlock(id) |
450 |
self.RefreshActionBlockModel(actionblock) |
|
451 |
self.Refresh() |
|
452 |
dialog.Destroy() |
|
453 |
||
454 |
def AddDivergence(self): |
|
455 |
if self.SelectedElement in self.Wires or isinstance(self.SelectedElement, Graphic_Group) or isinstance(self.SelectedElement, SFC_Step): |
|
456 |
dialog = DivergenceCreateDialog(self.Parent) |
|
457 |
if dialog.ShowModal() == wxID_OK: |
|
458 |
value = dialog.GetValues() |
|
459 |
if value["type"] == SELECTION_DIVERGENCE: |
|
460 |
if self.SelectedElement in self.Wires and isinstance(self.SelectedElement.EndConnected.GetParentBlock(), SFC_Step): |
|
461 |
self.SelectedElement.SetSelectedSegment(None) |
|
462 |
previous = self.SelectedElement.EndConnected |
|
463 |
next = self.SelectedElement.StartConnected |
|
464 |
self.SelectedElement.Clean() |
|
42 | 465 |
self.RemoveWire(self.SelectedElement) |
0 | 466 |
self.SelectedElement = None |
467 |
elif isinstance(self.SelectedElement, SFC_Step): |
|
468 |
connectors = self.SelectedElement.GetConnectors() |
|
469 |
if connectors["output"]: |
|
470 |
previous = connectors["output"] |
|
471 |
wires = previous.GetWires() |
|
472 |
if len(wires) != 1: |
|
473 |
return |
|
474 |
wire = wires[0][0] |
|
475 |
next = wire.StartConnected |
|
476 |
wire.Clean() |
|
42 | 477 |
self.RemoveWire(wire) |
0 | 478 |
else: |
479 |
self.SelectedElement.AddOutput() |
|
480 |
connectors = self.SelectedElement.GetConnectors() |
|
481 |
self.RefreshStepModel(self.SelectedElement) |
|
482 |
previous = connectors["output"] |
|
483 |
next = None |
|
484 |
else: |
|
485 |
return |
|
486 |
id = self.GetNewId() |
|
487 |
divergence = SFC_Divergence(self, SELECTION_DIVERGENCE, value["number"], id) |
|
488 |
pos = previous.GetPosition(False) |
|
489 |
previous_block = previous.GetParentBlock() |
|
490 |
wire_size = GetWireSize(previous_block) |
|
491 |
divergence.SetPosition(pos.x, pos.y + wire_size) |
|
492 |
divergence_connectors = divergence.GetConnectors() |
|
493 |
wire = self.ConnectConnectors(divergence_connectors["inputs"][0], previous) |
|
494 |
previous_block.RefreshOutputPosition() |
|
495 |
wire.SetPoints([wxPoint(pos.x, pos.y + wire_size), wxPoint(pos.x, pos.y)]) |
|
42 | 496 |
self.AddBlock(divergence) |
0 | 497 |
self.Controler.AddCurrentElementEditingDivergence(id, value["type"]) |
498 |
self.RefreshDivergenceModel(divergence) |
|
499 |
for index, connector in enumerate(divergence_connectors["outputs"]): |
|
500 |
if next: |
|
501 |
wire = self.ConnectConnectors(next, connector) |
|
502 |
pos = connector.GetPosition(False) |
|
503 |
next_pos = next.GetPosition(False) |
|
504 |
next_block = next.GetParentBlock() |
|
505 |
divergence.RefreshOutputPosition((0, pos.y + SFC_WIRE_MIN_SIZE - next_pos.y)) |
|
506 |
divergence.RefreshConnectedPosition(connector) |
|
507 |
wire.SetPoints([wxPoint(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wxPoint(pos.x, pos.y)]) |
|
508 |
next_block.RefreshModel() |
|
509 |
next = None |
|
510 |
else: |
|
511 |
transition = self.CreateTransition(connector) |
|
512 |
transition_connectors = transition.GetConnectors() |
|
513 |
step = self.CreateStep("Step", transition_connectors["output"]) |
|
514 |
elif value["type"] == SIMULTANEOUS_DIVERGENCE: |
|
515 |
if self.SelectedElement in self.Wires and isinstance(self.SelectedElement.EndConnected.GetParentBlock(), SFC_Transition): |
|
516 |
self.SelectedElement.SetSelectedSegment(None) |
|
517 |
previous = self.SelectedElement.EndConnected |
|
518 |
next = self.SelectedElement.StartConnected |
|
519 |
self.SelectedElement.Clean() |
|
42 | 520 |
self.RemoveWire(self.SelectedElement) |
0 | 521 |
self.SelectedElement = None |
522 |
elif isinstance(self.SelectedElement, SFC_Step): |
|
523 |
connectors = self.SelectedElement.GetConnectors() |
|
524 |
if connectors["output"]: |
|
525 |
previous = connectors["output"] |
|
526 |
wires = previous.GetWires() |
|
527 |
if len(wires) != 1: |
|
528 |
return |
|
529 |
wire = wires[0][0] |
|
530 |
next = wire.StartConnected |
|
531 |
wire.Clean() |
|
42 | 532 |
self.RemoveWire(wire) |
0 | 533 |
else: |
534 |
self.SelectedElement.AddOutput() |
|
535 |
connectors = self.SelectedElement.GetConnectors() |
|
536 |
self.RefreshStepModel(self.SelectedElement) |
|
537 |
previous = connectors["output"] |
|
538 |
next = None |
|
539 |
transition = self.CreateTransition(previous) |
|
540 |
transition_connectors = transition.GetConnectors() |
|
541 |
previous = transition_connectors["output"] |
|
542 |
else: |
|
543 |
return |
|
544 |
id = self.GetNewId() |
|
545 |
divergence = SFC_Divergence(self, SIMULTANEOUS_DIVERGENCE, value["number"], id) |
|
546 |
pos = previous.GetPosition(False) |
|
547 |
previous_block = previous.GetParentBlock() |
|
548 |
wire_size = GetWireSize(previous_block) |
|
549 |
divergence.SetPosition(pos.x, pos.y + wire_size) |
|
550 |
divergence_connectors = divergence.GetConnectors() |
|
551 |
wire = self.ConnectConnectors(divergence_connectors["inputs"][0], previous) |
|
552 |
previous_block.RefreshOutputPosition() |
|
553 |
wire.SetPoints([wxPoint(pos.x, pos.y + wire_size), wxPoint(pos.x, pos.y)]) |
|
42 | 554 |
self.AddBlock(divergence) |
0 | 555 |
self.Controler.AddCurrentElementEditingDivergence(id, value["type"]) |
556 |
self.RefreshDivergenceModel(divergence) |
|
557 |
for index, connector in enumerate(divergence_connectors["outputs"]): |
|
558 |
if next: |
|
559 |
wire = self.ConnectConnectors(next, connector) |
|
560 |
pos = connector.GetPosition(False) |
|
561 |
next_pos = next.GetPosition(False) |
|
562 |
next_block = next.GetParentBlock() |
|
563 |
divergence.RefreshOutputPosition((0, pos.y + SFC_WIRE_MIN_SIZE - next_pos.y)) |
|
564 |
divergence.RefreshConnectedPosition(connector) |
|
565 |
wire.SetPoints([wxPoint(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wxPoint(pos.x, pos.y)]) |
|
566 |
next_block.RefreshModel() |
|
567 |
next = None |
|
568 |
else: |
|
569 |
step = self.CreateStep("Step", connector) |
|
570 |
elif isinstance(self.SelectedElement, Graphic_Group) and len(self.SelectedElement.GetElements()) > 1: |
|
571 |
next = None |
|
572 |
for element in self.SelectedElement.GetElements(): |
|
573 |
connectors = element.GetConnectors() |
|
574 |
if not isinstance(element, SFC_Step) or connectors["output"] and next: |
|
575 |
return |
|
576 |
elif connectors["output"] and not next: |
|
577 |
wires = connectors["output"].GetWires() |
|
578 |
if len(wires) != 1: |
|
579 |
return |
|
580 |
if value["type"] == SELECTION_CONVERGENCE: |
|
581 |
transition = wires[0][0].StartConnected.GetParentBlock() |
|
582 |
transition_connectors = transition.GetConnectors() |
|
583 |
wires = transition_connectors["output"].GetWires() |
|
584 |
if len(wires) != 1: |
|
585 |
return |
|
586 |
wire = wires[0][0] |
|
587 |
next = wire.StartConnected |
|
588 |
wire.Clean() |
|
42 | 589 |
self.RemoveWire(wire) |
0 | 590 |
inputs = [] |
591 |
for input in self.SelectedElement.GetElements(): |
|
592 |
input_connectors = input.GetConnectors() |
|
593 |
if not input_connectors["output"]: |
|
594 |
input.AddOutput() |
|
595 |
input.RefreshModel() |
|
596 |
input_connectors = input.GetConnectors() |
|
597 |
if value["type"] == SELECTION_CONVERGENCE: |
|
598 |
transition = self.CreateTransition(input_connectors["output"]) |
|
599 |
transition_connectors = transition.GetConnectors() |
|
600 |
inputs.append(transition_connectors["output"]) |
|
601 |
else: |
|
602 |
inputs.append(input_connectors["output"]) |
|
603 |
elif value["type"] == SELECTION_CONVERGENCE: |
|
604 |
wires = input_connectors["output"].GetWires() |
|
605 |
transition = wires[0][0].StartConnected.GetParentBlock() |
|
606 |
transition_connectors = transition.GetConnectors() |
|
607 |
inputs.append(transition_connectors["output"]) |
|
608 |
else: |
|
609 |
inputs.append(input_connectors["output"]) |
|
610 |
id = self.GetNewId() |
|
611 |
divergence = SFC_Divergence(self, value["type"], len(inputs), id) |
|
612 |
pos = inputs[0].GetPosition(False) |
|
613 |
divergence.SetPosition(pos.x, pos.y + SFC_WIRE_MIN_SIZE) |
|
614 |
divergence_connectors = divergence.GetConnectors() |
|
615 |
for i, input in enumerate(inputs): |
|
616 |
pos = input.GetPosition(False) |
|
617 |
wire = self.ConnectConnectors(divergence_connectors["inputs"][i], input) |
|
618 |
wire_size = GetWireSize(input) |
|
619 |
wire.SetPoints([wxPoint(pos.x, pos.y + wire_size), wxPoint(pos.x, pos.y)]) |
|
620 |
input_block = input.GetParentBlock() |
|
621 |
input_block.RefreshOutputPosition() |
|
622 |
divergence.RefreshPosition() |
|
623 |
pos = divergence_connectors["outputs"][0].GetRelPosition() |
|
624 |
divergence.MoveConnector(divergence_connectors["outputs"][0], - pos.x) |
|
42 | 625 |
self.AddBlock(divergence) |
0 | 626 |
self.Controler.AddCurrentElementEditingDivergence(id, value["type"]) |
627 |
self.RefreshDivergenceModel(divergence) |
|
628 |
if next: |
|
629 |
wire = self.ConnectConnectors(next, divergence_connectors["outputs"][0]) |
|
630 |
pos = divergence_connectors["outputs"][0].GetPosition(False) |
|
631 |
next_pos = next.GetPosition(False) |
|
632 |
next_block = next.GetParentBlock() |
|
633 |
divergence.RefreshOutputPosition((0, pos.y + SFC_WIRE_MIN_SIZE - next_pos.y)) |
|
634 |
divergence.RefreshConnectedPosition(divergence_connectors["outputs"][0]) |
|
635 |
wire.SetPoints([wxPoint(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wxPoint(pos.x, pos.y)]) |
|
636 |
next_block.RefreshModel() |
|
637 |
else: |
|
638 |
if value["type"] == SELECTION_CONVERGENCE: |
|
639 |
previous = divergence_connectors["outputs"][0] |
|
640 |
else: |
|
641 |
transition = self.CreateTransition(divergence_connectors["outputs"][0]) |
|
642 |
transition_connectors = transition.GetConnectors() |
|
643 |
previous = transition_connectors["output"] |
|
644 |
self.CreateStep("Step", previous) |
|
645 |
self.Refresh() |
|
646 |
dialog.Destroy() |
|
647 |
||
648 |
def AddDivergenceBranch(self, divergence): |
|
649 |
if isinstance(divergence, SFC_Divergence): |
|
650 |
type = divergence.GetType() |
|
651 |
if type in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]: |
|
652 |
divergence.AddBranch() |
|
653 |
divergence_connectors = divergence.GetConnectors() |
|
654 |
if type == SELECTION_DIVERGENCE: |
|
655 |
transition = self.CreateTransition(divergence_connectors["outputs"][-1]) |
|
656 |
transition_connectors = transition.GetConnectors() |
|
657 |
previous = transition_connectors["output"] |
|
658 |
else: |
|
659 |
previous = divergence_connectors["outputs"][-1] |
|
660 |
step = self.CreateStep("Step", previous) |
|
661 |
self.Refresh() |
|
662 |
||
663 |
def AddJump(self): |
|
664 |
if isinstance(self.SelectedElement, SFC_Step) and not self.SelectedElement.Output: |
|
665 |
choices = [] |
|
666 |
for block in self.Blocks: |
|
667 |
if isinstance(block, SFC_Step): |
|
668 |
choices.append(block.GetName()) |
|
669 |
dialog = wxSingleChoiceDialog(self.Parent, "Add a new jump", "Please choose a target", choices, wxOK|wxCANCEL) |
|
670 |
if dialog.ShowModal() == wxID_OK: |
|
671 |
value = dialog.GetStringSelection() |
|
672 |
self.SelectedElement.AddOutput() |
|
673 |
self.RefreshStepModel(self.SelectedElement) |
|
674 |
step_connectors = self.SelectedElement.GetConnectors() |
|
675 |
transition = self.CreateTransition(step_connectors["output"]) |
|
676 |
transition_connectors = transition.GetConnectors() |
|
677 |
id = self.GetNewId() |
|
678 |
jump = SFC_Jump(self, value, id) |
|
679 |
pos = transition_connectors["output"].GetPosition(False) |
|
680 |
jump.SetPosition(pos.x, pos.y + SFC_WIRE_MIN_SIZE) |
|
42 | 681 |
self.AddBlock(jump) |
0 | 682 |
self.Controler.AddCurrentElementEditingJump(id) |
683 |
jump_connector = jump.GetConnector() |
|
684 |
wire = self.ConnectConnectors(jump_connector, transition_connectors["output"]) |
|
685 |
transition.RefreshOutputPosition() |
|
686 |
wire.SetPoints([wxPoint(pos.x, pos.y + SFC_WIRE_MIN_SIZE), wxPoint(pos.x, pos.y)]) |
|
687 |
self.RefreshJumpModel(jump) |
|
688 |
self.Refresh() |
|
689 |
dialog.Destroy() |
|
690 |
||
691 |
def AddComment(self, bbox): |
|
692 |
dialog = wxTextEntryDialog(self.Parent, "Add a new comment", "Please enter comment text", "", wxOK|wxCANCEL|wxTE_MULTILINE) |
|
693 |
if dialog.ShowModal() == wxID_OK: |
|
694 |
value = dialog.GetValue() |
|
695 |
id = self.GetNewId() |
|
696 |
comment = Comment(self, value, id) |
|
697 |
comment.SetPosition(bbox.x, bbox.y) |
|
698 |
min_width, min_height = comment.GetMinSize() |
|
699 |
comment.SetSize(max(min_width,bbox.width),max(min_height,bbox.height)) |
|
42 | 700 |
self.AddComment(comment) |
0 | 701 |
self.Controler.AddCurrentElementEditingComment(id) |
702 |
self.RefreshCommentModel(comment) |
|
703 |
self.Refresh() |
|
704 |
dialog.Destroy() |
|
705 |
||
706 |
def EditStepContent(self, step): |
|
9 | 707 |
dialog = StepNameDialog(self.Parent, "Edit step name", "Please enter step name", step.GetName(), wxOK|wxCANCEL) |
708 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
709 |
dialog.SetVariables(self.Controler.GetCurrentElementEditingInterfaceVars()) |
|
710 |
dialog.SetStepNames([block.GetName() for block in self.Blocks if isinstance(block, SFC_Step) and block.GetName() != step.GetName()]) |
|
0 | 711 |
if dialog.ShowModal() == wxID_OK: |
712 |
value = dialog.GetValue() |
|
713 |
step.SetName(value) |
|
714 |
min_size = step.GetMinSize() |
|
715 |
size = step.GetSize() |
|
716 |
step.UpdateSize(max(min_size[0], size[0]), max(min_size[1], size[1])) |
|
717 |
step.RefreshModel() |
|
718 |
self.Refresh() |
|
719 |
dialog.Destroy() |
|
720 |
||
721 |
def EditTransitionContent(self, transition): |
|
722 |
dialog = TransitionContentDialog(self.Parent) |
|
723 |
dialog.SetTransitions(self.Controler.GetCurrentElementEditingTransitions()) |
|
724 |
dialog.SetValues({"type":transition.GetType(),"value":transition.GetCondition()}) |
|
725 |
if dialog.ShowModal() == wxID_OK: |
|
726 |
values = dialog.GetValues() |
|
727 |
transition.SetType(values["type"]) |
|
728 |
transition.SetCondition(values["value"]) |
|
729 |
transition.RefreshModel() |
|
730 |
self.Refresh() |
|
731 |
dialog.Destroy() |
|
732 |
||
733 |
def EditJumpContent(self, jump): |
|
734 |
choices = [] |
|
735 |
for block in self.Blocks: |
|
736 |
if isinstance(block, SFC_Step): |
|
737 |
choices.append(block.GetName()) |
|
738 |
dialog = wxSingleChoiceDialog(self.Parent, "Edit jump target", "Please choose a target", choices, wxOK|wxCANCEL) |
|
739 |
dialog.SetSelection(choices.index(jump.GetTarget())) |
|
740 |
if dialog.ShowModal() == wxID_OK: |
|
741 |
value = dialog.GetStringSelection() |
|
742 |
jump.SetTarget(value) |
|
743 |
jump.RefreshModel() |
|
744 |
self.Refresh() |
|
745 |
dialog.Destroy() |
|
746 |
||
747 |
def EditActionBlockContent(self, actionblock): |
|
748 |
dialog = ActionBlockDialog(self.Parent) |
|
749 |
dialog.SetQualifierList(self.Controler.GetQualifierTypes()) |
|
750 |
dialog.SetActionList(self.Controler.GetCurrentElementEditingActions()) |
|
751 |
dialog.SetVariableList(self.Controler.GetCurrentElementEditingInterfaceVars()) |
|
752 |
dialog.SetValues(actionblock.GetActions()) |
|
753 |
if dialog.ShowModal() == wxID_OK: |
|
754 |
actions = dialog.GetValues() |
|
755 |
actionblock.SetActions(actions) |
|
756 |
actionblock.RefreshModel() |
|
757 |
self.Refresh() |
|
758 |
dialog.Destroy() |
|
759 |
||
760 |
||
761 |
#------------------------------------------------------------------------------- |
|
762 |
# Delete element functions |
|
763 |
#------------------------------------------------------------------------------- |
|
764 |
||
765 |
def DeleteStep(self, step): |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
766 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
767 |
Viewer.DeleteStep(self, step) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
768 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
769 |
step_connectors = step.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
770 |
if not step.GetInitial() or not step_connectors["output"]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
771 |
previous = step.GetPreviousConnector() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
772 |
if previous: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
773 |
previous_block = previous.GetParentBlock() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
774 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
775 |
previous_block = None |
0 | 776 |
next = step.GetNextConnector() |
777 |
if next: |
|
778 |
next_block = next.GetParentBlock() |
|
779 |
else: |
|
780 |
next_block = None |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
781 |
if isinstance(next_block, SFC_Transition): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
782 |
self.RemoveTransition(next_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
783 |
next = step.GetNextConnector() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
784 |
if next: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
785 |
next_block = next.GetParentBlock() |
0 | 786 |
else: |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
787 |
next_block = None |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
788 |
elif isinstance(previous_block, SFC_Transition): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
789 |
self.RemoveTransition(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
790 |
previous = step.GetPreviousConnector() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
791 |
if previous: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
792 |
previous_block = previous.GetParentBlock() |
0 | 793 |
else: |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
794 |
previous_block = None |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
795 |
wire = self.RemoveStep(step) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
796 |
self.SelectedElement = None |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
797 |
if next_block: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
798 |
if isinstance(next_block, SFC_Divergence) and next_block.GetType() == SIMULTANEOUS_CONVERGENCE and isinstance(previous_block, SFC_Divergence) and previous_block.GetType() == SIMULTANEOUS_DIVERGENCE: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
799 |
wire.Clean() |
42 | 800 |
self.RemoveWire(wire) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
801 |
next_block.RemoveBranch(next) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
802 |
if next_block.GetBranchNumber() < 2: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
803 |
self.DeleteDivergence(next_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
804 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
805 |
next_block.RefreshModel() |
0 | 806 |
previous_block.RemoveBranch(previous) |
807 |
if previous_block.GetBranchNumber() < 2: |
|
808 |
self.DeleteDivergence(previous_block) |
|
809 |
else: |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
810 |
previous_block.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
811 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
812 |
pos = previous.GetPosition(False) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
813 |
next_pos = next.GetPosition(False) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
814 |
wire_size = GetWireSize(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
815 |
previous_block.RefreshOutputPosition((0, pos.y + wire_size - next_pos.y)) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
816 |
wire.SetPoints([wxPoint(pos.x, pos.y + wire_size), wxPoint(pos.x, pos.y)]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
817 |
if isinstance(next_block, SFC_Divergence): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
818 |
next_block.RefreshPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
819 |
previous_block.RefreshOutputModel(True) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
820 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
821 |
if isinstance(previous_block, SFC_Step): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
822 |
previous_block.RemoveOutput() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
823 |
self.RefreshStepModel(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
824 |
elif isinstance(previous_block, SFC_Divergence): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
825 |
if previous_block.GetType() in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
826 |
self.DeleteDivergence(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
827 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
828 |
previous_block.RemoveBranch(previous) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
829 |
if previous_block.GetBranchNumber() < 2: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
830 |
self.DeleteDivergence(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
831 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
832 |
self.RefreshDivergenceModel(previous_block) |
0 | 833 |
|
834 |
def DeleteTransition(self, transition): |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
835 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
836 |
Viewer.DeleteTransition(self, transition) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
837 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
838 |
previous = transition.GetPreviousConnector() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
839 |
previous_block = previous.GetParentBlock() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
840 |
next = transition.GetNextConnector() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
841 |
next_block = next.GetParentBlock() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
842 |
if isinstance(previous_block, SFC_Divergence) and previous_block.GetType() == SELECTION_DIVERGENCE and isinstance(next_block, SFC_Divergence) and next_block.GetType() == SELECTION_CONVERGENCE: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
843 |
wires = previous.GetWires() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
844 |
if len(wires) != 1: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
845 |
return |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
846 |
wire = wires[0][0] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
847 |
wire.Clean() |
42 | 848 |
self.RemoveWire(wire) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
849 |
wires = next.GetWires() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
850 |
if len(wires) != 1: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
851 |
return |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
852 |
wire = wires[0][0] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
853 |
wire.Clean() |
42 | 854 |
self.RemoveWire(wire) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
855 |
transition.Clean() |
44 | 856 |
self.RemoveBlock(transition) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
857 |
self.Controler.RemoveCurrentElementEditingInstance(transition.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
858 |
previous_block.RemoveBranch(previous) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
859 |
if previous_block.GetBranchNumber() < 2: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
860 |
self.DeleteDivergence(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
861 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
862 |
self.RefreshDivergenceModel(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
863 |
next_block.RemoveBranch(next) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
864 |
if next_block.GetBranchNumber() < 2: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
865 |
self.DeleteDivergence(next_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
866 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
867 |
self.RefreshDivergenceModel(next_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
868 |
self.Parent.RefreshProjectTree() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
869 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
870 |
def DeleteDivergence(self, divergence): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
871 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
872 |
Viewer.DeleteDivergence(self, divergence) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
873 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
874 |
connectors = divergence.GetConnectors() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
875 |
type = divergence.GetType() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
876 |
if type in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
877 |
wires = connectors["outputs"][0].GetWires() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
878 |
if len(wires) > 1: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
879 |
return |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
880 |
elif len(wires) == 1: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
881 |
next = wires[0][0].StartConnected |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
882 |
next_block = next.GetParentBlock() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
883 |
wire = wires[0][0] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
884 |
wire.Clean() |
42 | 885 |
self.RemoveWire(wire) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
886 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
887 |
next = None |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
888 |
next_block = None |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
889 |
for index, connector in enumerate(connectors["inputs"]): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
890 |
if next and index == 0: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
891 |
wires = connector.GetWires() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
892 |
wire = wires[0][0] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
893 |
previous = wires[0][0].EndConnected |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
894 |
wire.Clean() |
42 | 895 |
self.RemoveWire(wire) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
896 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
897 |
if type == SELECTION_CONVERGENCE: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
898 |
wires = connector.GetWires() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
899 |
previous_block = wires[0][0].EndConnected.GetParentBlock() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
900 |
self.RemoveTransition(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
901 |
wires = connector.GetWires() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
902 |
wire = wires[0][0] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
903 |
previous_connector = wire.EndConnected |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
904 |
previous_block = previous_connector.GetParentBlock() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
905 |
wire.Clean() |
42 | 906 |
self.RemoveWire(wire) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
907 |
if isinstance(previous_block, SFC_Step): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
908 |
previous_block.RemoveOutput() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
909 |
self.RefreshStepModel(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
910 |
elif isinstance(previous_block, SFC_Divergence): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
911 |
if previous_block.GetType() in [SELECTION_DIVERGENCE, SIMULTANEOUS_DIVERGENCE]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
912 |
previous_block.RemoveBranch(previous_connector) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
913 |
if previous_block.GetBranchNumber() < 2: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
914 |
self.DeleteDivergence(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
915 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
916 |
self.RefreshDivergenceModel(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
917 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
918 |
self.DeleteDivergence(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
919 |
divergence.Clean() |
44 | 920 |
self.RemoveBlock(divergence) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
921 |
self.Controler.RemoveCurrentElementEditingInstance(divergence.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
922 |
if next: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
923 |
wire = self.ConnectConnectors(next, previous) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
924 |
previous_block = previous.GetParentBlock() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
925 |
pos = previous.GetPosition(False) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
926 |
next_pos = next.GetPosition(False) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
927 |
wire_size = GetWireSize(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
928 |
previous_block.RefreshOutputPosition((0, previous_pos.y + wire_size - next_pos.y)) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
929 |
wire.SetPoints([wxPoint(previous_pos.x, previous_pos.y + wire_size), |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
930 |
wxPoint(previous_pos.x, previous_pos.y)]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
931 |
if isinstance(next_block, SFC_Divergence): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
932 |
next_block.RefreshPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
933 |
previous_block.RefreshOutputModel(True) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
934 |
elif divergence.GetBranchNumber() == 1: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
935 |
wires = connectors["inputs"][0].GetWires() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
936 |
if len(wires) != 1: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
937 |
return |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
938 |
wire = wires[0][0] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
939 |
previous = wire.EndConnected |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
940 |
previous_block = previous.GetParentBlock() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
941 |
wire.Clean() |
42 | 942 |
self.RemoveWire(wire) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
943 |
wires = connectors["outputs"][0].GetWires() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
944 |
if len(wires) != 1: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
945 |
return |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
946 |
wire = wires[0][0] |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
947 |
next = wire.StartConnected |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
948 |
next_block = next.GetParentBlock() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
949 |
wire.Clean() |
42 | 950 |
self.RemoveWire(wire) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
951 |
divergence.Clean() |
44 | 952 |
self.RemoveBlock(divergence) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
953 |
self.Controler.RemoveCurrentElementEditingInstance(divergence.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
954 |
wire = self.ConnectConnectors(next, previous) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
955 |
previous_pos = previous.GetPosition(False) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
956 |
next_pos = next.GetPosition(False) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
957 |
wire_size = GetWireSize(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
958 |
previous_block.RefreshOutputPosition((previous_pos.x - next_pos.x, previous_pos.y + wire_size - next_pos.y)) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
959 |
wire.SetPoints([wxPoint(previous_pos.x, previous_pos.y + wire_size), |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
960 |
wxPoint(previous_pos.x, previous_pos.y)]) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
961 |
if isinstance(next_block, SFC_Divergence): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
962 |
next_block.RefreshPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
963 |
previous_block.RefreshOutputModel(True) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
964 |
self.Parent.RefreshProjectTree() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
965 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
966 |
def DeleteJump(self, jump): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
967 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
968 |
Viewer.DeleteJump(self, jump) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
969 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
970 |
previous = jump.GetPreviousConnector() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
971 |
previous_block = previous.GetParentBlock() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
972 |
if isinstance(previous_block, SFC_Transition): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
973 |
self.RemoveTransition(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
974 |
previous = jump.GetPreviousConnector() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
975 |
if previous: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
976 |
previous_block = previous.GetParentBlock() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
977 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
978 |
previous_block = None |
0 | 979 |
wires = previous.GetWires() |
980 |
if len(wires) != 1: |
|
981 |
return |
|
982 |
wire = wires[0][0] |
|
983 |
wire.Clean() |
|
42 | 984 |
self.RemoveWire(wire) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
985 |
jump.Clean() |
44 | 986 |
self.RemoveBlock(jump) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
987 |
self.Controler.RemoveCurrentElementEditingInstance(jump.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
988 |
if isinstance(previous_block, SFC_Step): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
989 |
previous_block.RemoveOutput() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
990 |
self.RefreshStepModel(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
991 |
elif isinstance(previous_block, SFC_Divergence): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
992 |
if previous_block.GetType() in [SELECTION_CONVERGENCE, SIMULTANEOUS_CONVERGENCE]: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
993 |
self.DeleteDivergence(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
994 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
995 |
previous_block.RemoveBranch(previous) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
996 |
if previous_block.GetBranchNumber() < 2: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
997 |
self.DeleteDivergence(previous_block) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
998 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
999 |
previous_block.RefreshModel() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1000 |
self.Parent.RefreshProjectTree() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1001 |
|
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1002 |
def DeleteActionBlock(self, actionblock): |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1003 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1004 |
Viewer.DeleteActionBlock(self, actionblock) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1005 |
else: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1006 |
connector = actionblock.GetConnector() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1007 |
wires = connector.GetWires() |
0 | 1008 |
if len(wires) != 1: |
1009 |
return |
|
1010 |
wire = wires[0][0] |
|
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1011 |
step = wire.EndConnected.GetParentBlock() |
0 | 1012 |
wire.Clean() |
42 | 1013 |
self.RemoveWire(wire) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1014 |
actionblock.Clean() |
44 | 1015 |
self.RemoveBlock(actionblock) |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1016 |
self.Controler.RemoveCurrentElementEditingInstance(actionblock.GetId()) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1017 |
step.RemoveAction() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1018 |
self.RefreshStepModel(step) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1019 |
step.RefreshOutputPosition() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1020 |
step.RefreshOutputModel(True) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1021 |
self.Parent.RefreshProjectTree() |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1022 |
|
0 | 1023 |
def DeleteWire(self, wire): |
28
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1024 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1025 |
Viewer.DeleteWire(self, wire) |
fc23e1f415d8
Adding support for concurrent overriden standard function
lbessard
parents:
27
diff
changeset
|
1026 |