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