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