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