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