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