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