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