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