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