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