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