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