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