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