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