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