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