author | Andrey Skvortsov <andrej.skvortzov@gmail.com> |
Sat, 09 Jun 2018 17:14:56 +0300 | |
changeset 2182 | eeca1aff0691 |
parent 2177 | 10aa87518401 |
child 2233 | 32445e3c9cfc |
permissions | -rwxr-xr-x |
1511
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
1 |
#!/usr/bin/env python |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
2 |
# -*- coding: utf-8 -*- |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
3 |
|
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
6 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
7 |
# Copyright (C) 2007: Edouard TISSERANT and Laurent BESSARD |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
8 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
10 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
11 |
# This program is free software; you can redistribute it and/or |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
12 |
# modify it under the terms of the GNU General Public License |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
13 |
# as published by the Free Software Foundation; either version 2 |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
15 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
16 |
# This program is distributed in the hope that it will be useful, |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
19 |
# GNU General Public License for more details. |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
20 |
# |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
21 |
# You should have received a copy of the GNU General Public License |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
22 |
# along with this program; if not, write to the Free Software |
91538d0c242c
add copyright notices to python files where there were missing, that
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1490
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 24 |
|
1881
091005ec69c4
fix pylint py3k conversion warning: "(no-absolute-import) import missing `from __future__ import absolute_import`"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1878
diff
changeset
|
25 |
from __future__ import absolute_import |
1732
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
26 |
import sys |
814 | 27 |
import cPickle |
28 |
from types import TupleType |
|
1783
3311eea28d56
clean-up: fix PEP8 E402 module level import not at top of file
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
29 |
import base64 |
814 | 30 |
|
1732
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
31 |
import wx |
94ffe74e6895
clean-up: fix PEP8 E401 multiple imports on one line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
32 |
import wx.grid |
814 | 33 |
import wx.aui |
34 |
||
35 |
from editors.EditorPanel import EditorPanel |
|
36 |
from editors.SFCViewer import SFC_Viewer |
|
37 |
from editors.LDViewer import LD_Viewer |
|
38 |
from editors.TextViewer import TextViewer |
|
39 |
from editors.Viewer import Viewer, ZOOM_FACTORS |
|
40 |
from editors.ResourceEditor import ConfigurationEditor, ResourceEditor |
|
41 |
from editors.DataTypeEditor import DataTypeEditor |
|
42 |
from PLCControler import * |
|
1193
59c196884fec
Moved and start to rewrite DebugVariablePanel splitting it into multiple files
Laurent Bessard
parents:
1188
diff
changeset
|
43 |
from controls import CustomTree, LibraryPanel, PouInstanceVariablesPanel, SearchResultPanel |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1193
diff
changeset
|
44 |
from controls.DebugVariablePanel import DebugVariablePanel |
819 | 45 |
from dialogs import ProjectDialog, PouDialog, PouTransitionDialog, PouActionDialog, FindInPouDialog, SearchInProjectDialog |
814 | 46 |
from util.BitmapLibrary import GetBitmap |
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
47 |
from plcopen.types_enums import * |
814 | 48 |
|
49 |
# Define PLCOpenEditor controls id |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
50 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
51 |
ID_PLCOPENEDITOR, ID_PLCOPENEDITORLEFTNOTEBOOK, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
52 |
ID_PLCOPENEDITORBOTTOMNOTEBOOK, ID_PLCOPENEDITORRIGHTNOTEBOOK, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
53 |
ID_PLCOPENEDITORPROJECTTREE, ID_PLCOPENEDITORMAINSPLITTER, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
54 |
ID_PLCOPENEDITORSECONDSPLITTER, ID_PLCOPENEDITORTHIRDSPLITTER, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
55 |
ID_PLCOPENEDITORLIBRARYPANEL, ID_PLCOPENEDITORLIBRARYSEARCHCTRL, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
56 |
ID_PLCOPENEDITORLIBRARYTREE, ID_PLCOPENEDITORLIBRARYCOMMENT, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
57 |
ID_PLCOPENEDITORTABSOPENED, ID_PLCOPENEDITORTABSOPENED, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
58 |
ID_PLCOPENEDITOREDITORMENUTOOLBAR, ID_PLCOPENEDITOREDITORTOOLBAR, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
59 |
ID_PLCOPENEDITORPROJECTPANEL, |
814 | 60 |
] = [wx.NewId() for _init_ctrls in range(17)] |
61 |
||
62 |
# Define PLCOpenEditor EditMenu extra items id |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
63 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
64 |
ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, ID_PLCOPENEDITOREDITMENUADDDATATYPE, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
65 |
ID_PLCOPENEDITOREDITMENUADDFUNCTION, ID_PLCOPENEDITOREDITMENUADDFUNCTIONBLOCK, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
66 |
ID_PLCOPENEDITOREDITMENUADDPROGRAM, ID_PLCOPENEDITOREDITMENUADDCONFIGURATION, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
67 |
ID_PLCOPENEDITOREDITMENUFINDNEXT, ID_PLCOPENEDITOREDITMENUFINDPREVIOUS, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
68 |
ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, ID_PLCOPENEDITOREDITMENUADDRESOURCE |
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1364
diff
changeset
|
69 |
] = [wx.NewId() for _init_coll_EditMenu_Items in range(10)] |
814 | 70 |
|
71 |
# Define PLCOpenEditor DisplayMenu extra items id |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
72 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
73 |
ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
74 |
ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE, |
1530
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
75 |
] = [wx.NewId() for _init_coll_DisplayMenu_Items in range(2)] |
814 | 76 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
77 |
# ------------------------------------------------------------------------------- |
814 | 78 |
# EditorToolBar definitions |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
79 |
# ------------------------------------------------------------------------------- |
814 | 80 |
|
81 |
# Define PLCOpenEditor Toolbar items id |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
82 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
83 |
ID_PLCOPENEDITOREDITORTOOLBARSELECTION, ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
84 |
ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, ID_PLCOPENEDITOREDITORTOOLBARBLOCK, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
85 |
ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, ID_PLCOPENEDITOREDITORTOOLBARWIRE, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
86 |
ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, ID_PLCOPENEDITOREDITORTOOLBARRUNG, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
87 |
ID_PLCOPENEDITOREDITORTOOLBARCOIL, ID_PLCOPENEDITOREDITORTOOLBARCONTACT, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
88 |
ID_PLCOPENEDITOREDITORTOOLBARBRANCH, ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
89 |
ID_PLCOPENEDITOREDITORTOOLBARSTEP, ID_PLCOPENEDITOREDITORTOOLBARTRANSITION, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
90 |
ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
91 |
ID_PLCOPENEDITOREDITORTOOLBARJUMP, ID_PLCOPENEDITOREDITORTOOLBARMOTION, |
814 | 92 |
] = [wx.NewId() for _init_coll_DefaultEditorToolBar_Items in range(18)] |
93 |
||
94 |
||
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
95 |
# Define behaviour of each Toolbar item according to current POU body type |
814 | 96 |
# Informations meaning are in this order: |
97 |
# - Item is toggled |
|
98 |
# - PLCOpenEditor mode where item is displayed (could be more then one) |
|
99 |
# - Item id |
|
100 |
# - Item callback function name |
|
101 |
# - Item icon filename |
|
102 |
# - Item tooltip text |
|
103 |
EditorToolBarItems = { |
|
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
104 |
"FBD": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
105 |
ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
106 |
"move", _("Move the view")), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
107 |
(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
108 |
ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
109 |
"add_comment", _("Create a new comment")), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
110 |
(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
111 |
ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
112 |
"add_variable", _("Create a new variable")), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
113 |
(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
114 |
ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
115 |
"add_block", _("Create a new block")), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
116 |
(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
117 |
ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
118 |
"add_connection", _("Create a new connection"))], |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
119 |
"LD": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
120 |
ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
121 |
"move", _("Move the view")), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
122 |
(True, FREEDRAWING_MODE, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
123 |
ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
124 |
"add_comment", _("Create a new comment")), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
125 |
(True, FREEDRAWING_MODE, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
126 |
ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
127 |
"add_powerrail", _("Create a new power rail")), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
128 |
(False, DRIVENDRAWING_MODE, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
129 |
ID_PLCOPENEDITOREDITORTOOLBARRUNG, "OnRungTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
130 |
"add_rung", _("Create a new rung")), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
131 |
(True, FREEDRAWING_MODE, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
132 |
ID_PLCOPENEDITOREDITORTOOLBARCOIL, "OnCoilTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
133 |
"add_coil", _("Create a new coil")), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
134 |
(False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
135 |
ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
136 |
"add_contact", _("Create a new contact")), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
137 |
(False, DRIVENDRAWING_MODE, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
138 |
ID_PLCOPENEDITOREDITORTOOLBARBRANCH, "OnBranchTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
139 |
"add_branch", _("Create a new branch")), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
140 |
(True, FREEDRAWING_MODE, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
141 |
ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
142 |
"add_variable", _("Create a new variable")), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
143 |
(False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
144 |
ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
145 |
"add_block", _("Create a new block")), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
146 |
(True, FREEDRAWING_MODE, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
147 |
ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
148 |
"add_connection", _("Create a new connection"))], |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
149 |
"SFC": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
150 |
ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
151 |
"move", _("Move the view")), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
152 |
(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
153 |
ID_PLCOPENEDITOREDITORTOOLBARCOMMENT, "OnCommentTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
154 |
"add_comment", _("Create a new comment")), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
155 |
(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
156 |
ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP, "OnInitialStepTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
157 |
"add_initial_step", _("Create a new initial step")), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
158 |
(False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
159 |
ID_PLCOPENEDITOREDITORTOOLBARSTEP, "OnStepTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
160 |
"add_step", _("Create a new step")), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
161 |
(True, FREEDRAWING_MODE, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
162 |
ID_PLCOPENEDITOREDITORTOOLBARTRANSITION, "OnTransitionTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
163 |
"add_transition", _("Create a new transition")), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
164 |
(False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
165 |
ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK, "OnActionBlockTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
166 |
"add_action", _("Create a new action block")), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
167 |
(False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
168 |
ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE, "OnDivergenceTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
169 |
"add_divergence", _("Create a new divergence")), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
170 |
(False, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
171 |
ID_PLCOPENEDITOREDITORTOOLBARJUMP, "OnJumpTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
172 |
"add_jump", _("Create a new jump")), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
173 |
(True, FREEDRAWING_MODE, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
174 |
ID_PLCOPENEDITOREDITORTOOLBARVARIABLE, "OnVariableTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
175 |
"add_variable", _("Create a new variable")), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
176 |
(True, FREEDRAWING_MODE, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
177 |
ID_PLCOPENEDITOREDITORTOOLBARBLOCK, "OnBlockTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
178 |
"add_block", _("Create a new block")), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
179 |
(True, FREEDRAWING_MODE, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
180 |
ID_PLCOPENEDITOREDITORTOOLBARCONNECTION, "OnConnectionTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
181 |
"add_connection", _("Create a new connection")), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
182 |
(True, FREEDRAWING_MODE, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
183 |
ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL, "OnPowerRailTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
184 |
"add_powerrail", _("Create a new power rail")), |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
185 |
(True, FREEDRAWING_MODE, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
186 |
ID_PLCOPENEDITOREDITORTOOLBARCONTACT, "OnContactTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
187 |
"add_contact", _("Create a new contact"))], |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
188 |
"ST": [], |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
189 |
"IL": [], |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
190 |
"debug": [(True, FREEDRAWING_MODE | DRIVENDRAWING_MODE, |
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
191 |
ID_PLCOPENEDITOREDITORTOOLBARMOTION, "OnMotionTool", |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
192 |
"move", _("Move the view"))], |
814 | 193 |
} |
194 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
195 |
# ------------------------------------------------------------------------------- |
814 | 196 |
# Helper Functions |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
197 |
# ------------------------------------------------------------------------------- |
814 | 198 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
199 |
|
814 | 200 |
def EncodeFileSystemPath(path, use_base64=True): |
201 |
path = path.encode(sys.getfilesystemencoding()) |
|
202 |
if use_base64: |
|
203 |
return base64.encodestring(path) |
|
204 |
return path |
|
205 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
206 |
|
814 | 207 |
def DecodeFileSystemPath(path, is_base64=True): |
208 |
if is_base64: |
|
209 |
path = base64.decodestring(path) |
|
210 |
return unicode(path, sys.getfilesystemencoding()) |
|
211 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
212 |
|
814 | 213 |
def AppendMenu(parent, help, id, kind, text): |
2177
10aa87518401
Drop support for wxPython 2.6 and below
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2169
diff
changeset
|
214 |
parent.Append(help=help, id=id, kind=kind, text=text) |
814 | 215 |
|
1749
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
216 |
|
1773
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
217 |
[ |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
218 |
TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, PROJECTTREE, |
38fde37c3766
clean-up: fix PEP8 E124 closing bracket does not match visual indentation
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1768
diff
changeset
|
219 |
POUINSTANCEVARIABLESPANEL, LIBRARYTREE, SCALING, PAGETITLES |
814 | 220 |
] = range(10) |
221 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
222 |
|
814 | 223 |
def GetShortcutKeyCallbackFunction(viewer_function): |
224 |
def ShortcutKeyFunction(self, event): |
|
225 |
control = self.FindFocus() |
|
226 |
if control is not None and control.GetName() in ["Viewer", "TextViewer"]: |
|
227 |
getattr(control.ParentWindow, viewer_function)() |
|
228 |
elif isinstance(control, wx.stc.StyledTextCtrl): |
|
229 |
getattr(control, viewer_function)() |
|
230 |
elif isinstance(control, wx.TextCtrl): |
|
231 |
control.ProcessEvent(event) |
|
232 |
return ShortcutKeyFunction |
|
233 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
234 |
|
814 | 235 |
def GetDeleteElementFunction(remove_function, parent_type=None, check_function=None): |
236 |
def DeleteElementFunction(self, selected): |
|
237 |
name = self.ProjectTree.GetItemText(selected) |
|
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
238 |
if check_function is None or check_function(name): |
814 | 239 |
if parent_type is not None: |
240 |
item_infos = self.ProjectTree.GetPyData(selected) |
|
241 |
parent_name = item_infos["tagname"].split("::")[1] |
|
242 |
remove_function(self.Controler, parent_name, name) |
|
243 |
else: |
|
244 |
remove_function(self.Controler, name) |
|
245 |
return DeleteElementFunction |
|
246 |
||
1749
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
247 |
|
814 | 248 |
if wx.Platform == '__WXMSW__': |
249 |
TAB_BORDER = 6 |
|
250 |
NOTEBOOK_BORDER = 6 |
|
251 |
else: |
|
252 |
TAB_BORDER = 7 |
|
253 |
NOTEBOOK_BORDER = 2 |
|
254 |
||
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
255 |
|
814 | 256 |
def SimplifyTabLayout(tabs, rect): |
257 |
for tab in tabs: |
|
258 |
if tab["pos"][0] == rect.x: |
|
259 |
others = [t for t in tabs if t != tab] |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
260 |
others.sort(lambda x, y: cmp(x["pos"][0], y["pos"][0])) |
814 | 261 |
for other in others: |
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
262 |
if other["pos"][1] == tab["pos"][1] and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
263 |
other["size"][1] == tab["size"][1] and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
264 |
other["pos"][0] == tab["pos"][0] + tab["size"][0] + TAB_BORDER: |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
265 |
|
814 | 266 |
tab["size"] = (tab["size"][0] + other["size"][0] + TAB_BORDER, tab["size"][1]) |
267 |
tab["pages"].extend(other["pages"]) |
|
268 |
tabs.remove(other) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
269 |
|
814 | 270 |
if tab["size"][0] == rect.width: |
271 |
return True |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
272 |
|
814 | 273 |
elif tab["pos"][1] == rect.y: |
274 |
others = [t for t in tabs if t != tab] |
|
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
275 |
others.sort(lambda x, y: cmp(x["pos"][1], y["pos"][1])) |
814 | 276 |
for other in others: |
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
277 |
if other["pos"][0] == tab["pos"][0] and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
278 |
other["size"][0] == tab["size"][0] and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
279 |
other["pos"][1] == tab["pos"][1] + tab["size"][1] + TAB_BORDER: |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
280 |
|
814 | 281 |
tab["size"] = (tab["size"][0], tab["size"][1] + other["size"][1] + TAB_BORDER) |
282 |
tab["pages"].extend(other["pages"]) |
|
283 |
tabs.remove(other) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
284 |
|
814 | 285 |
if tab["size"][1] == rect.height: |
286 |
return True |
|
287 |
return False |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
288 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
289 |
|
814 | 290 |
def ComputeTabsLayout(tabs, rect): |
291 |
if len(tabs) == 0: |
|
292 |
return tabs |
|
293 |
if len(tabs) == 1: |
|
294 |
return tabs[0] |
|
295 |
split = None |
|
1855
f33942053466
fix pylint warning "(undefined-loop-variable) Using possibly undefined loop variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
296 |
split_id = None |
814 | 297 |
for idx, tab in enumerate(tabs): |
298 |
if len(tab["pages"]) == 0: |
|
1765
ccf59c1f0b45
clean-up: fix PEP8 W602 deprecated form of raising exception
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1763
diff
changeset
|
299 |
raise ValueError("Not possible") |
814 | 300 |
if tab["size"][0] == rect.width: |
301 |
if tab["pos"][1] == rect.y: |
|
302 |
split = (wx.TOP, float(tab["size"][1]) / float(rect.height)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
303 |
split_rect = wx.Rect(rect.x, rect.y + tab["size"][1] + TAB_BORDER, |
814 | 304 |
rect.width, rect.height - tab["size"][1] - TAB_BORDER) |
305 |
elif tab["pos"][1] == rect.height + 1 - tab["size"][1]: |
|
306 |
split = (wx.BOTTOM, 1.0 - float(tab["size"][1]) / float(rect.height)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
307 |
split_rect = wx.Rect(rect.x, rect.y, |
814 | 308 |
rect.width, rect.height - tab["size"][1] - TAB_BORDER) |
1855
f33942053466
fix pylint warning "(undefined-loop-variable) Using possibly undefined loop variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
309 |
split_id = idx |
814 | 310 |
break |
311 |
elif tab["size"][1] == rect.height: |
|
312 |
if tab["pos"][0] == rect.x: |
|
313 |
split = (wx.LEFT, float(tab["size"][0]) / float(rect.width)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
314 |
split_rect = wx.Rect(rect.x + tab["size"][0] + TAB_BORDER, rect.y, |
814 | 315 |
rect.width - tab["size"][0] - TAB_BORDER, rect.height) |
316 |
elif tab["pos"][0] == rect.width + 1 - tab["size"][0]: |
|
317 |
split = (wx.RIGHT, 1.0 - float(tab["size"][0]) / float(rect.width)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
318 |
split_rect = wx.Rect(rect.x, rect.y, |
814 | 319 |
rect.width - tab["size"][0] - TAB_BORDER, rect.height) |
2169
baa0c5111457
fix type introduced by f33942053466 (fix pylint warning "(undefined-loop-variable) Using possibly undefined loop variable 'X'")
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2167
diff
changeset
|
320 |
split_id = idx |
814 | 321 |
break |
1743
c3c3d1318130
clean-up: fix PEP8 E711 comparison to None should be 'if cond is not None:'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1742
diff
changeset
|
322 |
if split is not None: |
1855
f33942053466
fix pylint warning "(undefined-loop-variable) Using possibly undefined loop variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
323 |
split_tab = tabs.pop(split_id) |
814 | 324 |
return {"split": split, |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
325 |
"tab": split_tab, |
814 | 326 |
"others": ComputeTabsLayout(tabs, split_rect)} |
327 |
else: |
|
328 |
if SimplifyTabLayout(tabs, rect): |
|
329 |
return ComputeTabsLayout(tabs, rect) |
|
330 |
return tabs |
|
331 |
||
1749
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
332 |
|
1855
f33942053466
fix pylint warning "(undefined-loop-variable) Using possibly undefined loop variable 'X'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
333 |
UNEDITABLE_NAMES_DICT = dict([(_(n), n) for n in UNEDITABLE_NAMES]) |
814 | 334 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
335 |
|
814 | 336 |
class IDEFrame(wx.Frame): |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
337 |
"""IDEFrame Base Class""" |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
338 |
|
814 | 339 |
def _init_coll_MenuBar_Menus(self, parent): |
340 |
parent.Append(menu=self.FileMenu, title=_(u'&File')) |
|
341 |
parent.Append(menu=self.EditMenu, title=_(u'&Edit')) |
|
342 |
parent.Append(menu=self.DisplayMenu, title=_(u'&Display')) |
|
343 |
parent.Append(menu=self.HelpMenu, title=_(u'&Help')) |
|
344 |
||
345 |
def _init_coll_FileMenu_Items(self, parent): |
|
346 |
pass |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
347 |
|
814 | 348 |
def _init_coll_AddMenu_Items(self, parent, add_config=True): |
349 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDDATATYPE, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
350 |
kind=wx.ITEM_NORMAL, text=_(u'&Data Type')) |
814 | 351 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDFUNCTION, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
352 |
kind=wx.ITEM_NORMAL, text=_(u'&Function')) |
814 | 353 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDFUNCTIONBLOCK, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
354 |
kind=wx.ITEM_NORMAL, text=_(u'Function &Block')) |
814 | 355 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDPROGRAM, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
356 |
kind=wx.ITEM_NORMAL, text=_(u'&Program')) |
1401
611fded24ce4
Pair with matiec a51a3bb4d613. Re-enable resource add/remove, updated CFLAGS, disabled broken global FG test in tests/python
Edouard Tisserant
parents:
1364
diff
changeset
|
357 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDRESOURCE, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
358 |
kind=wx.ITEM_NORMAL, text=_(u'&Resource')) |
814 | 359 |
if add_config: |
360 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUADDCONFIGURATION, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
361 |
kind=wx.ITEM_NORMAL, text=_(u'&Configuration')) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
362 |
|
814 | 363 |
def _init_coll_EditMenu_Items(self, parent): |
364 |
AppendMenu(parent, help='', id=wx.ID_UNDO, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
365 |
kind=wx.ITEM_NORMAL, text=_(u'Undo') + '\tCTRL+Z') |
814 | 366 |
AppendMenu(parent, help='', id=wx.ID_REDO, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
367 |
kind=wx.ITEM_NORMAL, text=_(u'Redo') + '\tCTRL+Y') |
814 | 368 |
parent.AppendSeparator() |
369 |
AppendMenu(parent, help='', id=wx.ID_CUT, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
370 |
kind=wx.ITEM_NORMAL, text=_(u'Cut') + '\tCTRL+X') |
814 | 371 |
AppendMenu(parent, help='', id=wx.ID_COPY, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
372 |
kind=wx.ITEM_NORMAL, text=_(u'Copy') + '\tCTRL+C') |
814 | 373 |
AppendMenu(parent, help='', id=wx.ID_PASTE, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
374 |
kind=wx.ITEM_NORMAL, text=_(u'Paste') + '\tCTRL+V') |
814 | 375 |
parent.AppendSeparator() |
376 |
AppendMenu(parent, help='', id=wx.ID_FIND, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
377 |
kind=wx.ITEM_NORMAL, text=_(u'Find') + '\tCTRL+F') |
814 | 378 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUFINDNEXT, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
379 |
kind=wx.ITEM_NORMAL, text=_(u'Find Next') + '\tCTRL+K') |
814 | 380 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUFINDPREVIOUS, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
381 |
kind=wx.ITEM_NORMAL, text=_(u'Find Previous') + '\tCTRL+SHIFT+K') |
814 | 382 |
parent.AppendSeparator() |
383 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
384 |
kind=wx.ITEM_NORMAL, text=_(u'Search in Project') + '\tCTRL+SHIFT+F') |
814 | 385 |
parent.AppendSeparator() |
386 |
add_menu = wx.Menu(title='') |
|
387 |
self._init_coll_AddMenu_Items(add_menu) |
|
388 |
parent.AppendMenu(wx.ID_ADD, _(u"&Add Element"), add_menu) |
|
389 |
AppendMenu(parent, help='', id=wx.ID_SELECTALL, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
390 |
kind=wx.ITEM_NORMAL, text=_(u'Select All') + '\tCTRL+A') |
814 | 391 |
AppendMenu(parent, help='', id=wx.ID_DELETE, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
392 |
kind=wx.ITEM_NORMAL, text=_(u'&Delete')) |
814 | 393 |
self.Bind(wx.EVT_MENU, self.OnUndoMenu, id=wx.ID_UNDO) |
394 |
self.Bind(wx.EVT_MENU, self.OnRedoMenu, id=wx.ID_REDO) |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
395 |
# self.Bind(wx.EVT_MENU, self.OnEnableUndoRedoMenu, id=ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO) |
814 | 396 |
self.Bind(wx.EVT_MENU, self.OnCutMenu, id=wx.ID_CUT) |
397 |
self.Bind(wx.EVT_MENU, self.OnCopyMenu, id=wx.ID_COPY) |
|
398 |
self.Bind(wx.EVT_MENU, self.OnPasteMenu, id=wx.ID_PASTE) |
|
399 |
self.Bind(wx.EVT_MENU, self.OnFindMenu, id=wx.ID_FIND) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
400 |
self.Bind(wx.EVT_MENU, self.OnFindNextMenu, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
401 |
id=ID_PLCOPENEDITOREDITMENUFINDNEXT) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
402 |
self.Bind(wx.EVT_MENU, self.OnFindPreviousMenu, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
403 |
id=ID_PLCOPENEDITOREDITMENUFINDPREVIOUS) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
404 |
self.Bind(wx.EVT_MENU, self.OnSearchInProjectMenu, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
405 |
id=ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
406 |
self.Bind(wx.EVT_MENU, self.OnSearchInProjectMenu, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
407 |
id=ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT) |
814 | 408 |
self.Bind(wx.EVT_MENU, self.OnAddDataTypeMenu, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
409 |
id=ID_PLCOPENEDITOREDITMENUADDDATATYPE) |
814 | 410 |
self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction("function"), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
411 |
id=ID_PLCOPENEDITOREDITMENUADDFUNCTION) |
814 | 412 |
self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction("functionBlock"), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
413 |
id=ID_PLCOPENEDITOREDITMENUADDFUNCTIONBLOCK) |
814 | 414 |
self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction("program"), |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
415 |
id=ID_PLCOPENEDITOREDITMENUADDPROGRAM) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
416 |
self.Bind(wx.EVT_MENU, self.AddResourceMenu, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
417 |
id=ID_PLCOPENEDITOREDITMENUADDRESOURCE) |
814 | 418 |
self.Bind(wx.EVT_MENU, self.OnAddConfigurationMenu, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
419 |
id=ID_PLCOPENEDITOREDITMENUADDCONFIGURATION) |
814 | 420 |
self.Bind(wx.EVT_MENU, self.OnSelectAllMenu, id=wx.ID_SELECTALL) |
421 |
self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=wx.ID_DELETE) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
422 |
|
814 | 423 |
self.AddToMenuToolBar([(wx.ID_UNDO, "undo", _(u'Undo'), None), |
424 |
(wx.ID_REDO, "redo", _(u'Redo'), None), |
|
425 |
None, |
|
426 |
(wx.ID_CUT, "cut", _(u'Cut'), None), |
|
427 |
(wx.ID_COPY, "copy", _(u'Copy'), None), |
|
428 |
(wx.ID_PASTE, "paste", _(u'Paste'), None), |
|
429 |
None, |
|
430 |
(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, "find", _(u'Search in Project'), None)]) |
|
431 |
||
432 |
def _init_coll_DisplayMenu_Items(self, parent): |
|
433 |
AppendMenu(parent, help='', id=wx.ID_REFRESH, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
434 |
kind=wx.ITEM_NORMAL, text=_(u'Refresh') + '\tCTRL+R') |
814 | 435 |
if self.EnableDebug: |
436 |
AppendMenu(parent, help='', id=wx.ID_CLEAR, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
437 |
kind=wx.ITEM_NORMAL, text=_(u'Clear Errors') + '\tCTRL+K') |
814 | 438 |
parent.AppendSeparator() |
439 |
zoommenu = wx.Menu(title='') |
|
440 |
parent.AppendMenu(wx.ID_ZOOM_FIT, _("Zoom"), zoommenu) |
|
441 |
for idx, value in enumerate(ZOOM_FACTORS): |
|
442 |
new_id = wx.NewId() |
|
443 |
AppendMenu(zoommenu, help='', id=new_id, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
444 |
kind=wx.ITEM_RADIO, text=str(int(round(value * 100))) + "%") |
814 | 445 |
self.Bind(wx.EVT_MENU, self.GenerateZoomFunction(idx), id=new_id) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
446 |
|
814 | 447 |
parent.AppendSeparator() |
1530
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
448 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE, |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
449 |
kind=wx.ITEM_NORMAL, text=_(u'Switch perspective') + '\tF12') |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
450 |
self.Bind(wx.EVT_MENU, self.SwitchFullScrMode, id=ID_PLCOPENEDITORDISPLAYMENUSWITCHPERSPECTIVE) |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
451 |
|
814 | 452 |
AppendMenu(parent, help='', id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
453 |
kind=wx.ITEM_NORMAL, text=_(u'Reset Perspective')) |
814 | 454 |
self.Bind(wx.EVT_MENU, self.OnResetPerspective, id=ID_PLCOPENEDITORDISPLAYMENURESETPERSPECTIVE) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
455 |
|
814 | 456 |
self.Bind(wx.EVT_MENU, self.OnRefreshMenu, id=wx.ID_REFRESH) |
457 |
if self.EnableDebug: |
|
458 |
self.Bind(wx.EVT_MENU, self.OnClearErrorsMenu, id=wx.ID_CLEAR) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
459 |
|
814 | 460 |
def _init_coll_HelpMenu_Items(self, parent): |
461 |
pass |
|
462 |
||
463 |
def _init_utils(self): |
|
464 |
self.MenuBar = wx.MenuBar() |
|
465 |
||
466 |
self.FileMenu = wx.Menu(title='') |
|
467 |
self.EditMenu = wx.Menu(title='') |
|
468 |
self.DisplayMenu = wx.Menu(title='') |
|
469 |
self.HelpMenu = wx.Menu(title='') |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
470 |
|
814 | 471 |
self._init_coll_MenuBar_Menus(self.MenuBar) |
472 |
self._init_coll_FileMenu_Items(self.FileMenu) |
|
473 |
self._init_coll_EditMenu_Items(self.EditMenu) |
|
474 |
self._init_coll_DisplayMenu_Items(self.DisplayMenu) |
|
475 |
self._init_coll_HelpMenu_Items(self.HelpMenu) |
|
476 |
||
1490
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1480
diff
changeset
|
477 |
def _init_icon(self, parent): |
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1480
diff
changeset
|
478 |
if self.icon: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1710
diff
changeset
|
479 |
self.SetIcon(self.icon) |
1490
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1480
diff
changeset
|
480 |
elif parent and parent.icon: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1710
diff
changeset
|
481 |
self.SetIcon(parent.icon) |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1710
diff
changeset
|
482 |
|
814 | 483 |
def _init_ctrls(self, prnt): |
1490
f03bc6c9c146
make About and Find dialogs have the same icon as main Beremiz window
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1480
diff
changeset
|
484 |
self._init_icon(prnt) |
814 | 485 |
self.SetClientSize(wx.Size(1000, 600)) |
486 |
self.Bind(wx.EVT_ACTIVATE, self.OnActivated) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
487 |
|
814 | 488 |
self.TabsImageList = wx.ImageList(31, 16) |
489 |
self.TabsImageListIndexes = {} |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
490 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
491 |
# ----------------------------------------------------------------------- |
814 | 492 |
# Creating main structure |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
493 |
# ----------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
494 |
|
814 | 495 |
self.AUIManager = wx.aui.AuiManager(self) |
496 |
self.AUIManager.SetDockSizeConstraint(0.5, 0.5) |
|
497 |
self.Panes = {} |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
498 |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
499 |
self.LeftNoteBook = wx.aui.AuiNotebook( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
500 |
self, ID_PLCOPENEDITORLEFTNOTEBOOK, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
501 |
style=(wx.aui.AUI_NB_TOP | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
502 |
wx.aui.AUI_NB_TAB_SPLIT | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
503 |
wx.aui.AUI_NB_TAB_MOVE | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
504 |
wx.aui.AUI_NB_SCROLL_BUTTONS | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
505 |
wx.aui.AUI_NB_TAB_EXTERNAL_MOVE)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
506 |
self.LeftNoteBook.Bind(wx.aui.EVT_AUINOTEBOOK_ALLOW_DND, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
507 |
self.OnAllowNotebookDnD) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
508 |
self.AUIManager.AddPane( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
509 |
self.LeftNoteBook, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
510 |
wx.aui.AuiPaneInfo().Name("ProjectPane").Left().Layer(1). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
511 |
BestSize(wx.Size(300, 500)).CloseButton(False)) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
512 |
|
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
513 |
self.BottomNoteBook = wx.aui.AuiNotebook( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
514 |
self, ID_PLCOPENEDITORBOTTOMNOTEBOOK, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
515 |
style=(wx.aui.AUI_NB_TOP | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
516 |
wx.aui.AUI_NB_TAB_SPLIT | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
517 |
wx.aui.AUI_NB_TAB_MOVE | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
518 |
wx.aui.AUI_NB_SCROLL_BUTTONS | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
519 |
wx.aui.AUI_NB_TAB_EXTERNAL_MOVE)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
520 |
self.BottomNoteBook.Bind(wx.aui.EVT_AUINOTEBOOK_ALLOW_DND, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
521 |
self.OnAllowNotebookDnD) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
522 |
self.AUIManager.AddPane( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
523 |
self.BottomNoteBook, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
524 |
wx.aui.AuiPaneInfo().Name("ResultPane").Bottom().Layer(0). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
525 |
BestSize(wx.Size(800, 300)).CloseButton(False)) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
526 |
|
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
527 |
self.RightNoteBook = wx.aui.AuiNotebook( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
528 |
self, ID_PLCOPENEDITORRIGHTNOTEBOOK, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
529 |
style=(wx.aui.AUI_NB_TOP | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
530 |
wx.aui.AUI_NB_TAB_SPLIT | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
531 |
wx.aui.AUI_NB_TAB_MOVE | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
532 |
wx.aui.AUI_NB_SCROLL_BUTTONS | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
533 |
wx.aui.AUI_NB_TAB_EXTERNAL_MOVE)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
534 |
self.RightNoteBook.Bind(wx.aui.EVT_AUINOTEBOOK_ALLOW_DND, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
535 |
self.OnAllowNotebookDnD) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
536 |
self.AUIManager.AddPane( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
537 |
self.RightNoteBook, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
538 |
wx.aui.AuiPaneInfo().Name("LibraryPane").Right().Layer(0). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
539 |
BestSize(wx.Size(250, 400)).CloseButton(False)) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
540 |
|
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
541 |
self.TabsOpened = wx.aui.AuiNotebook( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
542 |
self, ID_PLCOPENEDITORTABSOPENED, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
543 |
style=(wx.aui.AUI_NB_DEFAULT_STYLE | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
544 |
wx.aui.AUI_NB_WINDOWLIST_BUTTON)) |
814 | 545 |
self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGING, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
546 |
self.OnPouSelectedChanging) |
814 | 547 |
self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CHANGED, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
548 |
self.OnPouSelectedChanged) |
814 | 549 |
self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_PAGE_CLOSE, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
550 |
self.OnPageClose) |
814 | 551 |
self.TabsOpened.Bind(wx.aui.EVT_AUINOTEBOOK_END_DRAG, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
552 |
self.OnPageDragged) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
553 |
self.AUIManager.AddPane(self.TabsOpened, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
554 |
wx.aui.AuiPaneInfo().CentrePane().Name("TabsPane")) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
555 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
556 |
# ----------------------------------------------------------------------- |
814 | 557 |
# Creating PLCopen Project Types Tree |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
558 |
# ----------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
559 |
|
814 | 560 |
self.MainTabs = {} |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
561 |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
562 |
self.ProjectPanel = wx.SplitterWindow( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
563 |
id=ID_PLCOPENEDITORPROJECTPANEL, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
564 |
name='ProjectPanel', parent=self.LeftNoteBook, point=wx.Point(0, 0), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
565 |
size=wx.Size(0, 0), style=wx.SP_3D) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
566 |
|
814 | 567 |
self.ProjectTree = CustomTree(id=ID_PLCOPENEDITORPROJECTTREE, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
568 |
name='ProjectTree', |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
569 |
parent=self.ProjectPanel, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
570 |
pos=wx.Point(0, 0), size=wx.Size(0, 0), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
571 |
style=wx.SUNKEN_BORDER, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
572 |
agwStyle=(wx.TR_HAS_BUTTONS | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
573 |
wx.TR_SINGLE | |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
574 |
wx.TR_EDIT_LABELS)) |
814 | 575 |
self.ProjectTree.SetBackgroundBitmap(GetBitmap("custom_tree_background"), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
576 |
wx.ALIGN_RIGHT | wx.ALIGN_BOTTOM) |
814 | 577 |
add_menu = wx.Menu() |
578 |
self._init_coll_AddMenu_Items(add_menu) |
|
579 |
self.ProjectTree.SetAddMenu(add_menu) |
|
1240
ceaf9b4c0f86
Fixed bug when drag'n dropping POU from project tree, POU editor is selected if open
Laurent Bessard
parents:
1233
diff
changeset
|
580 |
self.Bind(wx.EVT_TREE_ITEM_RIGHT_CLICK, self.OnProjectTreeRightUp, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
581 |
id=ID_PLCOPENEDITORPROJECTTREE) |
1240
ceaf9b4c0f86
Fixed bug when drag'n dropping POU from project tree, POU editor is selected if open
Laurent Bessard
parents:
1233
diff
changeset
|
582 |
self.ProjectTree.Bind(wx.EVT_LEFT_UP, self.OnProjectTreeLeftUp) |
ceaf9b4c0f86
Fixed bug when drag'n dropping POU from project tree, POU editor is selected if open
Laurent Bessard
parents:
1233
diff
changeset
|
583 |
self.Bind(wx.EVT_TREE_SEL_CHANGING, self.OnProjectTreeItemChanging, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
584 |
id=ID_PLCOPENEDITORPROJECTTREE) |
814 | 585 |
self.Bind(wx.EVT_TREE_BEGIN_DRAG, self.OnProjectTreeBeginDrag, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
586 |
id=ID_PLCOPENEDITORPROJECTTREE) |
814 | 587 |
self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnProjectTreeItemBeginEdit, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
588 |
id=ID_PLCOPENEDITORPROJECTTREE) |
814 | 589 |
self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnProjectTreeItemEndEdit, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
590 |
id=ID_PLCOPENEDITORPROJECTTREE) |
814 | 591 |
self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnProjectTreeItemActivated, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
592 |
id=ID_PLCOPENEDITORPROJECTTREE) |
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
593 |
self.ProjectTree.Bind(wx.EVT_MOTION, self.OnProjectTreeMotion) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
594 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
595 |
# ----------------------------------------------------------------------- |
814 | 596 |
# Creating PLCopen Project POU Instance Variables Panel |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
597 |
# ----------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
598 |
|
814 | 599 |
self.PouInstanceVariablesPanel = PouInstanceVariablesPanel(self.ProjectPanel, self, self.Controler, self.EnableDebug) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
600 |
|
814 | 601 |
self.MainTabs["ProjectPanel"] = (self.ProjectPanel, _("Project")) |
602 |
self.LeftNoteBook.AddPage(*self.MainTabs["ProjectPanel"]) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
603 |
|
814 | 604 |
self.ProjectPanel.SplitHorizontally(self.ProjectTree, self.PouInstanceVariablesPanel, 300) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
605 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
606 |
# ----------------------------------------------------------------------- |
814 | 607 |
# Creating Tool Bar |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
608 |
# ----------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
609 |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
610 |
MenuToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORMENUTOOLBAR, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
611 |
wx.DefaultPosition, wx.DefaultSize, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
612 |
wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER) |
814 | 613 |
MenuToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
614 |
MenuToolBar.Realize() |
|
615 |
self.Panes["MenuToolBar"] = MenuToolBar |
|
616 |
self.AUIManager.AddPane(MenuToolBar, wx.aui.AuiPaneInfo(). |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
617 |
Name("MenuToolBar").Caption(_("Menu ToolBar")). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
618 |
ToolbarPane().Top(). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
619 |
LeftDockable(False).RightDockable(False)) |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
620 |
|
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
621 |
EditorToolBar = wx.ToolBar(self, ID_PLCOPENEDITOREDITORTOOLBAR, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
622 |
wx.DefaultPosition, wx.DefaultSize, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
623 |
wx.TB_FLAT | wx.TB_NODIVIDER | wx.NO_BORDER) |
814 | 624 |
EditorToolBar.SetToolBitmapSize(wx.Size(25, 25)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
625 |
EditorToolBar.AddRadioTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
626 |
GetBitmap("select"), |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
627 |
wx.NullBitmap, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
628 |
_("Select an object")) |
814 | 629 |
EditorToolBar.Realize() |
630 |
self.Panes["EditorToolBar"] = EditorToolBar |
|
631 |
self.AUIManager.AddPane(EditorToolBar, wx.aui.AuiPaneInfo(). |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
632 |
Name("EditorToolBar").Caption(_("Editor ToolBar")). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
633 |
ToolbarPane().Top().Position(1). |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
634 |
LeftDockable(False).RightDockable(False)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
635 |
|
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
636 |
self.Bind(wx.EVT_MENU, self.OnSelectionTool, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
637 |
id=ID_PLCOPENEDITOREDITORTOOLBARSELECTION) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
638 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
639 |
# ----------------------------------------------------------------------- |
814 | 640 |
# Creating Search Panel |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
641 |
# ----------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
642 |
|
814 | 643 |
self.SearchResultPanel = SearchResultPanel(self.BottomNoteBook, self) |
644 |
self.MainTabs["SearchResultPanel"] = (self.SearchResultPanel, _("Search")) |
|
645 |
self.BottomNoteBook.AddPage(*self.MainTabs["SearchResultPanel"]) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
646 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
647 |
# ----------------------------------------------------------------------- |
814 | 648 |
# Creating Library Panel |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
649 |
# ----------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
650 |
|
814 | 651 |
self.LibraryPanel = LibraryPanel(self, True) |
652 |
self.MainTabs["LibraryPanel"] = (self.LibraryPanel, _("Library")) |
|
653 |
self.RightNoteBook.AddPage(*self.MainTabs["LibraryPanel"]) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
654 |
|
814 | 655 |
self._init_utils() |
656 |
self.SetMenuBar(self.MenuBar) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
657 |
|
814 | 658 |
if self.EnableDebug: |
902
ffa8ee5ee2fe
Adding support for defining a time range for DebugVariablePanel graphics and navigating across the recording.
Laurent Bessard
parents:
897
diff
changeset
|
659 |
self.DebugVariablePanel = DebugVariablePanel(self.RightNoteBook, self.Controler, self) |
814 | 660 |
self.MainTabs["DebugVariablePanel"] = (self.DebugVariablePanel, _("Debugger")) |
661 |
self.RightNoteBook.AddPage(*self.MainTabs["DebugVariablePanel"]) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
662 |
|
814 | 663 |
self.AUIManager.Update() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
664 |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
665 |
def __init__(self, parent, enable_debug=False): |
1836
d42b6cf00fa6
fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1783
diff
changeset
|
666 |
wx.Frame.__init__(self, id=ID_PLCOPENEDITOR, name='IDEFrame', |
d42b6cf00fa6
fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1783
diff
changeset
|
667 |
parent=parent, pos=wx.DefaultPosition, |
d42b6cf00fa6
fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1783
diff
changeset
|
668 |
size=wx.Size(1000, 600), |
d42b6cf00fa6
fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1783
diff
changeset
|
669 |
style=wx.DEFAULT_FRAME_STYLE) |
d42b6cf00fa6
fix error __init__ method from base class is not called
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1783
diff
changeset
|
670 |
|
814 | 671 |
self.Controler = None |
672 |
self.Config = wx.ConfigBase.Get() |
|
673 |
self.EnableDebug = enable_debug |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
674 |
|
814 | 675 |
self._init_ctrls(parent) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
676 |
|
814 | 677 |
# Define Tree item icon list |
678 |
self.TreeImageList = wx.ImageList(16, 16) |
|
679 |
self.TreeImageDict = {} |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
680 |
|
814 | 681 |
# Icons for languages |
682 |
for language in LANGUAGES: |
|
683 |
self.TreeImageDict[language] = self.TreeImageList.Add(GetBitmap(language)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
684 |
|
814 | 685 |
# Icons for other items |
686 |
for imgname, itemtype in [ |
|
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
687 |
# editables |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
688 |
("PROJECT", ITEM_PROJECT), |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
689 |
# ("POU", ITEM_POU), |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
690 |
# ("VARIABLE", ITEM_VARIABLE), |
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
691 |
("TRANSITION", ITEM_TRANSITION), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
692 |
("ACTION", ITEM_ACTION), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
693 |
("CONFIGURATION", ITEM_CONFIGURATION), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
694 |
("RESOURCE", ITEM_RESOURCE), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
695 |
("DATATYPE", ITEM_DATATYPE), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
696 |
# uneditables |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
697 |
("DATATYPES", ITEM_DATATYPES), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
698 |
("FUNCTION", ITEM_FUNCTION), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
699 |
("FUNCTIONBLOCK", ITEM_FUNCTIONBLOCK), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
700 |
("PROGRAM", ITEM_PROGRAM), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
701 |
("VAR_LOCAL", ITEM_VAR_LOCAL), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
702 |
("VAR_LOCAL", ITEM_VAR_GLOBAL), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
703 |
("VAR_LOCAL", ITEM_VAR_EXTERNAL), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
704 |
("VAR_LOCAL", ITEM_VAR_TEMP), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
705 |
("VAR_INPUT", ITEM_VAR_INPUT), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
706 |
("VAR_OUTPUT", ITEM_VAR_OUTPUT), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
707 |
("VAR_INOUT", ITEM_VAR_INOUT), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
708 |
("TRANSITIONS", ITEM_TRANSITIONS), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
709 |
("ACTIONS", ITEM_ACTIONS), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
710 |
("CONFIGURATIONS", ITEM_CONFIGURATIONS), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
711 |
("RESOURCES", ITEM_RESOURCES), |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
712 |
("PROPERTIES", ITEM_PROPERTIES)]: |
814 | 713 |
self.TreeImageDict[itemtype] = self.TreeImageList.Add(GetBitmap(imgname)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
714 |
|
814 | 715 |
# Assign icon list to TreeCtrls |
716 |
self.ProjectTree.SetImageList(self.TreeImageList) |
|
717 |
self.PouInstanceVariablesPanel.SetTreeImageList(self.TreeImageList) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
718 |
|
814 | 719 |
self.CurrentEditorToolBar = [] |
720 |
self.CurrentMenu = None |
|
721 |
self.SelectedItem = None |
|
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
722 |
self.LastToolTipItem = None |
814 | 723 |
self.SearchParams = None |
724 |
self.Highlights = {} |
|
725 |
self.DrawingMode = FREEDRAWING_MODE |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
726 |
# self.DrawingMode = DRIVENDRAWING_MODE |
814 | 727 |
self.AuiTabCtrl = [] |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
728 |
|
980
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
729 |
# Save default perspective |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
730 |
notebooks = {} |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
731 |
for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"), |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
732 |
(self.BottomNoteBook, "bottomnotebook"), |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
733 |
(self.RightNoteBook, "rightnotebook")]: |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
734 |
notebooks[entry_name] = self.SaveTabLayout(notebook) |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
735 |
self.DefaultPerspective = { |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
736 |
"perspective": self.AUIManager.SavePerspective(), |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
737 |
"notebooks": notebooks, |
c7ba67d01d65
Completely removed restore perspective and project layout process
Laurent Bessard
parents:
970
diff
changeset
|
738 |
} |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
739 |
|
814 | 740 |
# Initialize Printing configuring elements |
741 |
self.PrintData = wx.PrintData() |
|
742 |
self.PrintData.SetPaperId(wx.PAPER_A4) |
|
743 |
self.PrintData.SetPrintMode(wx.PRINT_MODE_PRINTER) |
|
744 |
self.PageSetupData = wx.PageSetupDialogData(self.PrintData) |
|
745 |
self.PageSetupData.SetMarginTopLeft(wx.Point(10, 15)) |
|
746 |
self.PageSetupData.SetMarginBottomRight(wx.Point(10, 20)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
747 |
|
814 | 748 |
self.SetRefreshFunctions() |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
749 |
self.SetDeleteFunctions() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
750 |
|
1700
df50e13a94d6
fix problem with hidden FindInPou dialog with wxPython 3.0 on Windows
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1635
diff
changeset
|
751 |
wx.CallAfter(self.InitFindDialog) |
df50e13a94d6
fix problem with hidden FindInPou dialog with wxPython 3.0 on Windows
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1635
diff
changeset
|
752 |
|
814 | 753 |
def __del__(self): |
754 |
self.FindDialog.Destroy() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
755 |
|
1700
df50e13a94d6
fix problem with hidden FindInPou dialog with wxPython 3.0 on Windows
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1635
diff
changeset
|
756 |
def InitFindDialog(self): |
df50e13a94d6
fix problem with hidden FindInPou dialog with wxPython 3.0 on Windows
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1635
diff
changeset
|
757 |
self.FindDialog = FindInPouDialog(self) |
df50e13a94d6
fix problem with hidden FindInPou dialog with wxPython 3.0 on Windows
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1635
diff
changeset
|
758 |
self.FindDialog.Hide() |
df50e13a94d6
fix problem with hidden FindInPou dialog with wxPython 3.0 on Windows
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1635
diff
changeset
|
759 |
|
814 | 760 |
def Show(self): |
761 |
wx.Frame.Show(self) |
|
762 |
wx.CallAfter(self.RestoreLastState) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
763 |
|
814 | 764 |
def OnActivated(self, event): |
765 |
if event.GetActive(): |
|
766 |
wx.CallAfter(self._Refresh, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
|
767 |
event.Skip() |
|
768 |
||
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
989
diff
changeset
|
769 |
def SelectTab(self, tab): |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
989
diff
changeset
|
770 |
for notebook in [self.LeftNoteBook, self.BottomNoteBook, self.RightNoteBook]: |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
989
diff
changeset
|
771 |
idx = notebook.GetPageIndex(tab) |
1015
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1010
diff
changeset
|
772 |
if idx != wx.NOT_FOUND and idx != notebook.GetSelection(): |
999
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
989
diff
changeset
|
773 |
notebook.SetSelection(idx) |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
989
diff
changeset
|
774 |
return |
cbab4c1635bd
Replaced LogConsole TextCtrl by StyledTextCtrl
Laurent Bessard
parents:
989
diff
changeset
|
775 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
776 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
777 |
# Saving and restoring frame organization functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
778 |
# ------------------------------------------------------------------------------- |
814 | 779 |
|
780 |
def GetTabInfos(self, tab): |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
781 |
for page_name, (page_ref, _page_title) in self.MainTabs.iteritems(): |
981
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
980
diff
changeset
|
782 |
if page_ref == tab: |
fc671a3e95a9
Fixed LogViewer scrollbar and scroll methods
Laurent Bessard
parents:
980
diff
changeset
|
783 |
return ("main", page_name) |
814 | 784 |
return None |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
785 |
|
814 | 786 |
def SaveTabLayout(self, notebook): |
787 |
tabs = [] |
|
788 |
for child in notebook.GetChildren(): |
|
789 |
if isinstance(child, wx.aui.AuiTabCtrl): |
|
790 |
if child.GetPageCount() > 0: |
|
791 |
pos = child.GetPosition() |
|
792 |
tab = {"pos": (pos.x, pos.y), "pages": []} |
|
793 |
tab_size = child.GetSize() |
|
794 |
for page_idx in xrange(child.GetPageCount()): |
|
795 |
page = child.GetWindowFromIdx(page_idx) |
|
1775
b45f2768fab1
clean-up: fix PEP8 E713 test for membership should be 'not in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
796 |
if "size" not in tab: |
814 | 797 |
tab["size"] = (tab_size[0], tab_size[1] + page.GetSize()[1]) |
798 |
tab_infos = self.GetTabInfos(page) |
|
799 |
if tab_infos is not None: |
|
800 |
tab["pages"].append((tab_infos, page_idx == child.GetActivePage())) |
|
801 |
tabs.append(tab) |
|
802 |
tabs.sort(lambda x, y: cmp(x["pos"], y["pos"])) |
|
803 |
size = notebook.GetSize() |
|
804 |
return ComputeTabsLayout(tabs, wx.Rect(1, 1, size[0] - NOTEBOOK_BORDER, size[1] - NOTEBOOK_BORDER)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
805 |
|
814 | 806 |
def LoadTab(self, notebook, page_infos): |
807 |
if page_infos[0] == "main": |
|
808 |
infos = self.MainTabs.get(page_infos[1]) |
|
809 |
if infos is not None: |
|
810 |
page_ref, page_title = infos |
|
811 |
notebook.AddPage(page_ref, page_title) |
|
812 |
return notebook.GetPageIndex(page_ref) |
|
813 |
elif page_infos[0] == "editor": |
|
814 |
tagname = page_infos[1] |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
815 |
page_ref = self.EditProjectElement(GetElementType(tagname), tagname) |
814 | 816 |
if page_ref is not None: |
817 |
page_ref.RefreshView() |
|
818 |
return notebook.GetPageIndex(page_ref) |
|
819 |
elif page_infos[0] == "debug": |
|
820 |
instance_path = page_infos[1] |
|
821 |
instance_infos = self.Controler.GetInstanceInfos(instance_path, self.EnableDebug) |
|
822 |
if instance_infos is not None: |
|
823 |
return notebook.GetPageIndex(self.OpenDebugViewer(instance_infos["class"], instance_path, instance_infos["type"])) |
|
824 |
return None |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
825 |
|
814 | 826 |
def LoadTabLayout(self, notebook, tabs, mode="all", first_index=None): |
827 |
if isinstance(tabs, ListType): |
|
828 |
if len(tabs) == 0: |
|
829 |
return |
|
1765
ccf59c1f0b45
clean-up: fix PEP8 W602 deprecated form of raising exception
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1763
diff
changeset
|
830 |
raise ValueError("Not supported") |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
831 |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
832 |
if "split" in tabs: |
814 | 833 |
self.LoadTabLayout(notebook, tabs["others"]) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
834 |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
835 |
split_dir, _split_ratio = tabs["split"] |
814 | 836 |
first_index = self.LoadTabLayout(notebook, tabs["tab"], mode="first") |
837 |
notebook.Split(first_index, split_dir) |
|
838 |
self.LoadTabLayout(notebook, tabs["tab"], mode="others", first_index=first_index) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
839 |
|
814 | 840 |
elif mode == "first": |
841 |
return self.LoadTab(notebook, tabs["pages"][0][0]) |
|
842 |
else: |
|
843 |
selected = first_index |
|
844 |
if mode == "others": |
|
845 |
add_tabs = tabs["pages"][1:] |
|
846 |
else: |
|
847 |
add_tabs = tabs["pages"] |
|
848 |
for page_infos, page_selected in add_tabs: |
|
849 |
page_idx = self.LoadTab(notebook, page_infos) |
|
850 |
if page_selected: |
|
851 |
selected = page_idx |
|
852 |
if selected is not None: |
|
853 |
wx.CallAfter(notebook.SetSelection, selected) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
854 |
|
814 | 855 |
def ResetPerspective(self): |
856 |
if self.DefaultPerspective is not None: |
|
857 |
self.AUIManager.LoadPerspective(self.DefaultPerspective["perspective"]) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
858 |
|
814 | 859 |
for notebook in [self.LeftNoteBook, self.BottomNoteBook, self.RightNoteBook]: |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
860 |
for dummy in xrange(notebook.GetPageCount()): |
814 | 861 |
notebook.RemovePage(0) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
862 |
|
814 | 863 |
notebooks = self.DefaultPerspective["notebooks"] |
864 |
for notebook, entry_name in [(self.LeftNoteBook, "leftnotebook"), |
|
865 |
(self.BottomNoteBook, "bottomnotebook"), |
|
866 |
(self.RightNoteBook, "rightnotebook")]: |
|
867 |
self.LoadTabLayout(notebook, notebooks.get(entry_name)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
868 |
|
814 | 869 |
self._Refresh(EDITORTOOLBAR) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
870 |
|
814 | 871 |
def RestoreLastState(self): |
872 |
frame_size = None |
|
873 |
if self.Config.HasEntry("framesize"): |
|
874 |
frame_size = cPickle.loads(str(self.Config.Read("framesize"))) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
875 |
|
814 | 876 |
if frame_size is None: |
877 |
self.Maximize() |
|
878 |
else: |
|
879 |
self.SetClientSize(frame_size) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
880 |
|
814 | 881 |
def SaveLastState(self): |
882 |
if not self.IsMaximized(): |
|
883 |
self.Config.Write("framesize", cPickle.dumps(self.GetClientSize())) |
|
884 |
elif self.Config.HasEntry("framesize"): |
|
885 |
self.Config.DeleteEntry("framesize") |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
886 |
|
814 | 887 |
self.Config.Flush() |
888 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
889 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
890 |
# General Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
891 |
# ------------------------------------------------------------------------------- |
814 | 892 |
|
893 |
def SetRefreshFunctions(self): |
|
894 |
self.RefreshFunctions = { |
|
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
895 |
TITLE: self.RefreshTitle, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
896 |
EDITORTOOLBAR: self.RefreshEditorToolBar, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
897 |
FILEMENU: self.RefreshFileMenu, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
898 |
EDITMENU: self.RefreshEditMenu, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
899 |
DISPLAYMENU: self.RefreshDisplayMenu, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
900 |
PROJECTTREE: self.RefreshProjectTree, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
901 |
POUINSTANCEVARIABLESPANEL: self.RefreshPouInstanceVariablesPanel, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
902 |
LIBRARYTREE: self.RefreshLibraryPanel, |
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
903 |
SCALING: self.RefreshScaling, |
814 | 904 |
PAGETITLES: self.RefreshPageTitles} |
905 |
||
906 |
def _Refresh(self, *elements): |
|
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
907 |
"""Call Editor refresh functions. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
908 |
|
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
909 |
:param elements: List of elements to refresh. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
910 |
""" |
814 | 911 |
try: |
912 |
for element in elements: |
|
913 |
self.RefreshFunctions[element]() |
|
914 |
except wx.PyDeadObjectError: |
|
915 |
# ignore exceptions caused by refresh while quitting |
|
916 |
pass |
|
917 |
||
918 |
def OnPageClose(self, event): |
|
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
919 |
"""Callback function when AUINotebook Page closed with CloseButton |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
920 |
|
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
921 |
:param event: AUINotebook Event. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
922 |
""" |
814 | 923 |
selected = self.TabsOpened.GetSelection() |
924 |
if selected > -1: |
|
925 |
window = self.TabsOpened.GetPage(selected) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
926 |
|
814 | 927 |
if window.CheckSaveBeforeClosing(): |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
928 |
|
814 | 929 |
# Refresh all window elements that have changed |
930 |
wx.CallAfter(self._Refresh, TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
|
931 |
wx.CallAfter(self.RefreshTabCtrlEvent) |
|
932 |
wx.CallAfter(self.CloseFindInPouDialog) |
|
933 |
event.Skip() |
|
934 |
else: |
|
935 |
event.Veto() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
936 |
|
1015
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1010
diff
changeset
|
937 |
def GetCopyBuffer(self, primary_selection=False): |
814 | 938 |
data = None |
1028 | 939 |
if primary_selection and wx.Platform == '__WXMSW__': |
940 |
return data |
|
941 |
else: |
|
942 |
wx.TheClipboard.UsePrimarySelection(primary_selection) |
|
2166
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
943 |
|
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
944 |
if not wx.TheClipboard.IsOpened(): |
814 | 945 |
dataobj = wx.TextDataObject() |
2166
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
946 |
if wx.TheClipboard.Open(): |
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
947 |
success = wx.TheClipboard.GetData(dataobj) |
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
948 |
wx.TheClipboard.Close() |
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
949 |
if success: |
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
950 |
data = dataobj.GetText() |
814 | 951 |
return data |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
952 |
|
1015
50bb7cc12a84
Fixed LogConsole: set read only, enabled copy selected text with CTRL+C and primary selection
Laurent Bessard
parents:
1010
diff
changeset
|
953 |
def SetCopyBuffer(self, text, primary_selection=False): |
1028 | 954 |
if primary_selection and wx.Platform == '__WXMSW__': |
955 |
return |
|
956 |
else: |
|
957 |
wx.TheClipboard.UsePrimarySelection(primary_selection) |
|
2166
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
958 |
if not wx.TheClipboard.IsOpened(): |
814 | 959 |
data = wx.TextDataObject() |
960 |
data.SetText(text) |
|
2166
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
961 |
if wx.TheClipboard.Open(): |
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
962 |
wx.TheClipboard.SetData(data) |
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
963 |
wx.TheClipboard.Flush() |
5ce6d08ff2c7
make clipboard open minimal time as wxPython documentation recommends
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1978
diff
changeset
|
964 |
wx.TheClipboard.Close() |
2167
b8f795bdfe9f
fix hangs on mouse selection in case if wxPython uses wxWidgets with GTK3+ support
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2166
diff
changeset
|
965 |
wx.CallAfter(self.RefreshEditMenu) |
814 | 966 |
|
967 |
def GetDrawingMode(self): |
|
968 |
return self.DrawingMode |
|
969 |
||
970 |
def RefreshScaling(self): |
|
971 |
for i in xrange(self.TabsOpened.GetPageCount()): |
|
972 |
editor = self.TabsOpened.GetPage(i) |
|
973 |
editor.RefreshScaling() |
|
974 |
||
975 |
def EditProjectSettings(self): |
|
976 |
old_values = self.Controler.GetProjectProperties() |
|
977 |
dialog = ProjectDialog(self) |
|
978 |
dialog.SetValues(old_values) |
|
979 |
if dialog.ShowModal() == wx.ID_OK: |
|
980 |
new_values = dialog.GetValues() |
|
981 |
new_values["creationDateTime"] = old_values["creationDateTime"] |
|
982 |
if new_values != old_values: |
|
983 |
self.Controler.SetProjectProperties(None, new_values) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
984 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU, |
814 | 985 |
PROJECTTREE, POUINSTANCEVARIABLESPANEL, SCALING) |
986 |
dialog.Destroy() |
|
987 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
988 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
989 |
# Notebook Unified Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
990 |
# ------------------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
991 |
|
814 | 992 |
def AddPage(self, window, text): |
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
993 |
"""Function that add a tab in Notebook, calling refresh for tab DClick event |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
994 |
for wx.aui.AUINotebook. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
995 |
|
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
996 |
:param window: Panel to display in tab. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
997 |
:param text: title for the tab ctrl. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
998 |
""" |
814 | 999 |
self.TabsOpened.AddPage(window, text) |
1000 |
self.RefreshTabCtrlEvent() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1001 |
|
814 | 1002 |
def DeletePage(self, window): |
1003 |
for idx in xrange(self.TabsOpened.GetPageCount()): |
|
1004 |
if self.TabsOpened.GetPage(idx) == window: |
|
1005 |
self.TabsOpened.DeletePage(idx) |
|
1006 |
self.RefreshTabCtrlEvent() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1007 |
return |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1008 |
|
814 | 1009 |
def DeleteAllPages(self): |
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1010 |
"""Function that fix difference in deleting all tabs between |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1011 |
wx.Notebook and wx.aui.AUINotebook. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1012 |
""" |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
1013 |
for dummy in xrange(self.TabsOpened.GetPageCount()): |
814 | 1014 |
self.TabsOpened.DeletePage(0) |
1015 |
self.RefreshTabCtrlEvent() |
|
1016 |
||
1017 |
def SetPageBitmap(self, idx, bitmap): |
|
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1018 |
"""Function that fix difference in setting picture on tab between |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1019 |
wx.Notebook and wx.aui.AUINotebook. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1020 |
|
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1021 |
:param idx: Tab index. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1022 |
:param bitmap: wx.Bitmap to define on tab. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1023 |
:returns: True if operation succeeded |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1024 |
""" |
814 | 1025 |
return self.TabsOpened.SetPageBitmap(idx, bitmap) |
1026 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1027 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1028 |
# Dialog Message Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1029 |
# ------------------------------------------------------------------------------- |
814 | 1030 |
|
1031 |
def ShowErrorMessage(self, message): |
|
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1032 |
"""Function displaying an Error dialog in editor. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1033 |
|
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1034 |
:param message: The message to display. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1035 |
""" |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1036 |
dialog = wx.MessageDialog(self, message, _("Error"), wx.OK | wx.ICON_ERROR) |
814 | 1037 |
dialog.ShowModal() |
1038 |
dialog.Destroy() |
|
1039 |
||
1040 |
def CheckSaveBeforeClosing(self, title=_("Close Project")): |
|
1781
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1041 |
"""Function displaying an question dialog if project is not saved" |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1042 |
|
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1043 |
:returns: False if closing cancelled. |
b112bfdde5cc
clean-up: fix PEP8 E266 too many leading '#' for block comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1775
diff
changeset
|
1044 |
""" |
814 | 1045 |
if not self.Controler.ProjectIsSaved(): |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1046 |
dialog = wx.MessageDialog(self, _("There are changes, do you want to save?"), title, wx.YES_NO | wx.CANCEL | wx.ICON_QUESTION) |
814 | 1047 |
answer = dialog.ShowModal() |
1048 |
dialog.Destroy() |
|
1049 |
if answer == wx.ID_YES: |
|
1050 |
self.SaveProject() |
|
1051 |
elif answer == wx.ID_CANCEL: |
|
1052 |
return False |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1053 |
|
814 | 1054 |
for idx in xrange(self.TabsOpened.GetPageCount()): |
1055 |
window = self.TabsOpened.GetPage(idx) |
|
1056 |
if not window.CheckSaveBeforeClosing(): |
|
1057 |
return False |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1058 |
|
814 | 1059 |
return True |
1060 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1061 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1062 |
# File Menu Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1063 |
# ------------------------------------------------------------------------------- |
814 | 1064 |
|
1065 |
def RefreshFileMenu(self): |
|
1066 |
pass |
|
1067 |
||
1068 |
def ResetView(self): |
|
1069 |
self.DeleteAllPages() |
|
1070 |
self.ProjectTree.DeleteAllItems() |
|
1071 |
self.ProjectTree.Enable(False) |
|
1072 |
self.PouInstanceVariablesPanel.ResetView() |
|
1073 |
self.LibraryPanel.ResetTree() |
|
1074 |
self.LibraryPanel.SetController(None) |
|
1075 |
if self.EnableDebug: |
|
916
697d8b77d716
Improved matplotlib graphic debug panel implementation, adding force, release, split and delete graph buttons, replacing data grid by adding panel displaying non-numeric data between graphs
Laurent Bessard
parents:
909
diff
changeset
|
1076 |
self.DebugVariablePanel.ResetView() |
814 | 1077 |
self.Controler = None |
1078 |
||
1079 |
def OnCloseTabMenu(self, event): |
|
1080 |
selected = self.TabsOpened.GetSelection() |
|
1081 |
if selected >= 0: |
|
1082 |
self.TabsOpened.DeletePage(selected) |
|
1083 |
if self.TabsOpened.GetPageCount() > 0: |
|
1084 |
new_index = min(selected, self.TabsOpened.GetPageCount() - 1) |
|
1085 |
self.TabsOpened.SetSelection(new_index) |
|
1086 |
# Refresh all window elements that have changed |
|
1087 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, DISPLAYMENU) |
|
1088 |
self.RefreshTabCtrlEvent() |
|
1089 |
||
1090 |
def OnPageSetupMenu(self, event): |
|
1091 |
dialog = wx.PageSetupDialog(self, self.PageSetupData) |
|
1092 |
if dialog.ShowModal() == wx.ID_OK: |
|
1093 |
self.PageSetupData = wx.PageSetupDialogData(dialog.GetPageSetupData()) |
|
1094 |
self.PrintData = wx.PrintData(self.PageSetupData.GetPrintData()) |
|
1095 |
dialog.Destroy() |
|
1096 |
||
1097 |
def OnPreviewMenu(self, event): |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1098 |
selected = self.TabsOpened.GetSelection() |
814 | 1099 |
if selected != -1: |
1100 |
window = self.TabsOpened.GetPage(selected) |
|
1101 |
data = wx.PrintDialogData(self.PrintData) |
|
1102 |
properties = self.Controler.GetProjectProperties(window.IsDebugging()) |
|
1103 |
page_size = map(int, properties["pageSize"]) |
|
1104 |
margins = (self.PageSetupData.GetMarginTopLeft(), self.PageSetupData.GetMarginBottomRight()) |
|
1105 |
printout = GraphicPrintout(window, page_size, margins, True) |
|
1106 |
printout2 = GraphicPrintout(window, page_size, margins, True) |
|
1107 |
preview = wx.PrintPreview(printout, printout2, data) |
|
1108 |
||
1109 |
if preview.Ok(): |
|
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1110 |
preview_frame = wx.PreviewFrame(preview, self, _("Print preview"), style=wx.DEFAULT_FRAME_STYLE | wx.FRAME_FLOAT_ON_PARENT) |
814 | 1111 |
|
1112 |
preview_frame.Initialize() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1113 |
|
814 | 1114 |
preview_canvas = preview.GetCanvas() |
1115 |
preview_canvas.SetMinSize(preview_canvas.GetVirtualSize()) |
|
1116 |
preview_frame.Fit() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1117 |
|
814 | 1118 |
preview_frame.Show(True) |
1119 |
||
1120 |
def OnPrintMenu(self, event): |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1121 |
selected = self.TabsOpened.GetSelection() |
814 | 1122 |
if selected != -1: |
1123 |
window = self.TabsOpened.GetPage(selected) |
|
1124 |
dialog_data = wx.PrintDialogData(self.PrintData) |
|
1125 |
dialog_data.SetToPage(1) |
|
1126 |
properties = self.Controler.GetProjectProperties(window.IsDebugging()) |
|
1127 |
page_size = map(int, properties["pageSize"]) |
|
1128 |
margins = (self.PageSetupData.GetMarginTopLeft(), self.PageSetupData.GetMarginBottomRight()) |
|
1129 |
printer = wx.Printer(dialog_data) |
|
1130 |
printout = GraphicPrintout(window, page_size, margins) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1131 |
|
814 | 1132 |
if not printer.Print(self, printout, True) and printer.GetLastError() != wx.PRINTER_CANCELLED: |
1133 |
self.ShowErrorMessage(_("There was a problem printing.\nPerhaps your current printer is not set correctly?")) |
|
1134 |
printout.Destroy() |
|
1135 |
||
1136 |
def OnPropertiesMenu(self, event): |
|
1137 |
self.EditProjectSettings() |
|
1138 |
||
1139 |
def OnQuitMenu(self, event): |
|
1140 |
self.Close() |
|
1141 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1142 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1143 |
# Edit Menu Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1144 |
# ------------------------------------------------------------------------------- |
814 | 1145 |
|
1146 |
def RefreshEditMenu(self): |
|
1147 |
MenuToolBar = self.Panes["MenuToolBar"] |
|
1148 |
if self.Controler is not None: |
|
1149 |
selected = self.TabsOpened.GetSelection() |
|
1150 |
if selected > -1: |
|
1151 |
window = self.TabsOpened.GetPage(selected) |
|
1152 |
undo, redo = window.GetBufferState() |
|
1153 |
else: |
|
1154 |
undo, redo = self.Controler.GetBufferState() |
|
1155 |
self.EditMenu.Enable(wx.ID_UNDO, undo) |
|
1156 |
MenuToolBar.EnableTool(wx.ID_UNDO, undo) |
|
1157 |
self.EditMenu.Enable(wx.ID_REDO, redo) |
|
1158 |
MenuToolBar.EnableTool(wx.ID_REDO, redo) |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1159 |
# self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, True) |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1160 |
# self.EditMenu.Check(ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, |
814 | 1161 |
# self.Controler.IsProjectBufferEnabled()) |
1162 |
self.EditMenu.Enable(wx.ID_FIND, selected > -1) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1163 |
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUFINDNEXT, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1164 |
selected > -1 and self.SearchParams is not None) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1165 |
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUFINDPREVIOUS, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1166 |
selected > -1 and self.SearchParams is not None) |
814 | 1167 |
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, True) |
1168 |
MenuToolBar.EnableTool(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, True) |
|
1169 |
self.EditMenu.Enable(wx.ID_ADD, True) |
|
1170 |
self.EditMenu.Enable(wx.ID_DELETE, True) |
|
1171 |
if self.TabsOpened.GetPageCount() > 0: |
|
1172 |
self.EditMenu.Enable(wx.ID_CUT, True) |
|
1173 |
MenuToolBar.EnableTool(wx.ID_CUT, True) |
|
1174 |
self.EditMenu.Enable(wx.ID_COPY, True) |
|
1175 |
MenuToolBar.EnableTool(wx.ID_COPY, True) |
|
1176 |
if self.GetCopyBuffer() is not None: |
|
1177 |
self.EditMenu.Enable(wx.ID_PASTE, True) |
|
1178 |
MenuToolBar.EnableTool(wx.ID_PASTE, True) |
|
1179 |
else: |
|
1180 |
self.EditMenu.Enable(wx.ID_PASTE, False) |
|
1181 |
MenuToolBar.EnableTool(wx.ID_PASTE, False) |
|
1182 |
self.EditMenu.Enable(wx.ID_SELECTALL, True) |
|
1183 |
else: |
|
1184 |
self.EditMenu.Enable(wx.ID_CUT, False) |
|
1185 |
MenuToolBar.EnableTool(wx.ID_CUT, False) |
|
1186 |
self.EditMenu.Enable(wx.ID_COPY, False) |
|
1187 |
MenuToolBar.EnableTool(wx.ID_COPY, False) |
|
1188 |
self.EditMenu.Enable(wx.ID_PASTE, False) |
|
1189 |
MenuToolBar.EnableTool(wx.ID_PASTE, False) |
|
1190 |
self.EditMenu.Enable(wx.ID_SELECTALL, False) |
|
1191 |
else: |
|
1192 |
self.EditMenu.Enable(wx.ID_UNDO, False) |
|
1193 |
MenuToolBar.EnableTool(wx.ID_UNDO, False) |
|
1194 |
self.EditMenu.Enable(wx.ID_REDO, False) |
|
1195 |
MenuToolBar.EnableTool(wx.ID_REDO, False) |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1196 |
# self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUENABLEUNDOREDO, False) |
814 | 1197 |
self.EditMenu.Enable(wx.ID_CUT, False) |
1198 |
MenuToolBar.EnableTool(wx.ID_CUT, False) |
|
1199 |
self.EditMenu.Enable(wx.ID_COPY, False) |
|
1200 |
MenuToolBar.EnableTool(wx.ID_COPY, False) |
|
1201 |
self.EditMenu.Enable(wx.ID_PASTE, False) |
|
1202 |
MenuToolBar.EnableTool(wx.ID_PASTE, False) |
|
1203 |
self.EditMenu.Enable(wx.ID_SELECTALL, False) |
|
1204 |
self.EditMenu.Enable(wx.ID_FIND, False) |
|
1205 |
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUFINDNEXT, False) |
|
1206 |
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUFINDPREVIOUS, False) |
|
1207 |
self.EditMenu.Enable(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, False) |
|
1208 |
MenuToolBar.EnableTool(ID_PLCOPENEDITOREDITMENUSEARCHINPROJECT, False) |
|
1209 |
self.EditMenu.Enable(wx.ID_ADD, False) |
|
1210 |
self.EditMenu.Enable(wx.ID_DELETE, False) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1211 |
|
814 | 1212 |
def CloseTabsWithoutModel(self, refresh=True): |
1213 |
idxs = range(self.TabsOpened.GetPageCount()) |
|
1214 |
idxs.reverse() |
|
1215 |
for idx in idxs: |
|
1216 |
window = self.TabsOpened.GetPage(idx) |
|
1217 |
if window.HasNoModel(): |
|
1218 |
self.TabsOpened.DeletePage(idx) |
|
1219 |
if refresh: |
|
1220 |
self.RefreshEditor() |
|
1221 |
||
1222 |
def OnUndoMenu(self, event): |
|
1223 |
selected = self.TabsOpened.GetSelection() |
|
1224 |
if selected != -1: |
|
1225 |
window = self.TabsOpened.GetPage(selected) |
|
1226 |
window.Undo() |
|
1227 |
else: |
|
1228 |
self.Controler.LoadPrevious() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1229 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE, |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1230 |
SCALING, PAGETITLES) |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1231 |
|
814 | 1232 |
def OnRedoMenu(self, event): |
1233 |
selected = self.TabsOpened.GetSelection() |
|
1234 |
if selected != -1: |
|
1235 |
window = self.TabsOpened.GetPage(selected) |
|
1236 |
window.Redo() |
|
1237 |
else: |
|
1238 |
self.Controler.LoadNext() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1239 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE, |
814 | 1240 |
SCALING, PAGETITLES) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1241 |
|
814 | 1242 |
def OnEnableUndoRedoMenu(self, event): |
1243 |
self.Controler.EnableProjectBuffer(event.IsChecked()) |
|
1244 |
self.RefreshEditMenu() |
|
1245 |
||
1246 |
OnCutMenu = GetShortcutKeyCallbackFunction("Cut") |
|
1247 |
OnCopyMenu = GetShortcutKeyCallbackFunction("Copy") |
|
1248 |
OnPasteMenu = GetShortcutKeyCallbackFunction("Paste") |
|
1249 |
||
1250 |
def OnSelectAllMenu(self, event): |
|
1251 |
control = self.FindFocus() |
|
1252 |
if control is not None and control.GetName() == "Viewer": |
|
1253 |
control.Parent.SelectAll() |
|
1254 |
elif isinstance(control, wx.stc.StyledTextCtrl): |
|
1255 |
control.SelectAll() |
|
1256 |
elif isinstance(control, wx.TextCtrl): |
|
1257 |
control.SetSelection(0, control.GetLastPosition()) |
|
1258 |
elif isinstance(control, wx.ComboBox): |
|
1259 |
control.SetMark(0, control.GetLastPosition() + 1) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1260 |
|
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1261 |
def SetDeleteFunctions(self): |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1262 |
self.DeleteFunctions = { |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1263 |
ITEM_DATATYPE: GetDeleteElementFunction( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1264 |
PLCControler.ProjectRemoveDataType, |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1265 |
check_function=self.CheckDataTypeIsUsedBeforeDeletion), |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1266 |
ITEM_POU: GetDeleteElementFunction( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1267 |
PLCControler.ProjectRemovePou, |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1268 |
check_function=self.CheckPouIsUsedBeforeDeletion), |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1269 |
ITEM_TRANSITION: GetDeleteElementFunction( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1270 |
PLCControler.ProjectRemovePouTransition, ITEM_POU), |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1271 |
ITEM_ACTION: GetDeleteElementFunction( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1272 |
PLCControler.ProjectRemovePouAction, ITEM_POU), |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1273 |
ITEM_CONFIGURATION: GetDeleteElementFunction( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1274 |
PLCControler.ProjectRemoveConfiguration), |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1275 |
ITEM_RESOURCE: GetDeleteElementFunction( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1276 |
PLCControler.ProjectRemoveConfigurationResource, ITEM_CONFIGURATION) |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
1277 |
} |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1278 |
|
814 | 1279 |
def OnDeleteMenu(self, event): |
1280 |
window = self.FindFocus() |
|
1281 |
if window == self.ProjectTree or window is None: |
|
1282 |
selected = self.ProjectTree.GetSelection() |
|
1165
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1283 |
if selected is not None and selected.IsOk(): |
814 | 1284 |
function = self.DeleteFunctions.get(self.ProjectTree.GetPyData(selected)["type"], None) |
1285 |
if function is not None: |
|
1286 |
function(self, selected) |
|
1287 |
self.CloseTabsWithoutModel() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1288 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, PROJECTTREE, |
814 | 1289 |
POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
1290 |
elif isinstance(window, (Viewer, TextViewer)): |
|
1291 |
event = wx.KeyEvent(wx.EVT_CHAR._getEvtType()) |
|
1292 |
event.m_keyCode = wx.WXK_DELETE |
|
1293 |
window.ProcessEvent(event) |
|
1294 |
||
1295 |
def OnFindMenu(self, event): |
|
1296 |
if not self.FindDialog.IsShown(): |
|
1297 |
self.FindDialog.Show() |
|
1556
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1530
diff
changeset
|
1298 |
self.FindDialog.FindPattern.SetFocus() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1299 |
|
814 | 1300 |
def CloseFindInPouDialog(self): |
1301 |
selected = self.TabsOpened.GetSelection() |
|
1302 |
if selected == -1 and self.FindDialog.IsShown(): |
|
1303 |
self.FindDialog.Hide() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1304 |
|
814 | 1305 |
def OnFindNextMenu(self, event): |
1306 |
self.FindInPou(1) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1307 |
|
814 | 1308 |
def OnFindPreviousMenu(self, event): |
1309 |
self.FindInPou(-1) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1310 |
|
814 | 1311 |
def FindInPou(self, direction, search_params=None): |
1312 |
if search_params is not None: |
|
1313 |
self.SearchParams = search_params |
|
1314 |
selected = self.TabsOpened.GetSelection() |
|
1315 |
if selected != -1: |
|
1316 |
window = self.TabsOpened.GetPage(selected) |
|
1317 |
window.Find(direction, self.SearchParams) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1318 |
|
814 | 1319 |
def OnSearchInProjectMenu(self, event): |
1320 |
dialog = SearchInProjectDialog(self) |
|
1321 |
if dialog.ShowModal() == wx.ID_OK: |
|
1322 |
criteria = dialog.GetCriteria() |
|
1556
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1530
diff
changeset
|
1323 |
if len(criteria) > 0: |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1530
diff
changeset
|
1324 |
result = self.Controler.SearchInProject(criteria) |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1530
diff
changeset
|
1325 |
self.ClearSearchResults() |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1530
diff
changeset
|
1326 |
self.SearchResultPanel.SetSearchResults(criteria, result) |
32e9d0ef30dc
fix major bugs in Find and Search in Project functionality.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1530
diff
changeset
|
1327 |
self.SelectTab(self.SearchResultPanel) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1328 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1329 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1330 |
# Display Menu Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1331 |
# ------------------------------------------------------------------------------- |
814 | 1332 |
|
1333 |
def RefreshDisplayMenu(self): |
|
1334 |
if self.Controler is not None: |
|
1335 |
if self.TabsOpened.GetPageCount() > 0: |
|
1336 |
self.DisplayMenu.Enable(wx.ID_REFRESH, True) |
|
1337 |
selected = self.TabsOpened.GetSelection() |
|
1338 |
if selected != -1: |
|
1339 |
window = self.TabsOpened.GetPage(selected) |
|
1340 |
if isinstance(window, Viewer): |
|
1341 |
self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, True) |
|
1342 |
zoommenu = self.DisplayMenu.FindItemById(wx.ID_ZOOM_FIT).GetSubMenu() |
|
1343 |
zoomitem = zoommenu.FindItemByPosition(window.GetScale()) |
|
1344 |
zoomitem.Check(True) |
|
1345 |
else: |
|
1346 |
self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False) |
|
1347 |
else: |
|
1348 |
self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False) |
|
1349 |
else: |
|
1350 |
self.DisplayMenu.Enable(wx.ID_REFRESH, False) |
|
1351 |
self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False) |
|
1352 |
if self.EnableDebug: |
|
1353 |
self.DisplayMenu.Enable(wx.ID_CLEAR, True) |
|
1354 |
else: |
|
1355 |
self.DisplayMenu.Enable(wx.ID_REFRESH, False) |
|
1356 |
if self.EnableDebug: |
|
1357 |
self.DisplayMenu.Enable(wx.ID_CLEAR, False) |
|
1358 |
self.DisplayMenu.Enable(wx.ID_ZOOM_FIT, False) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1359 |
|
814 | 1360 |
def OnRefreshMenu(self, event): |
1361 |
self.RefreshEditor() |
|
1362 |
||
1363 |
def OnClearErrorsMenu(self, event): |
|
1364 |
self.ClearErrors() |
|
1365 |
||
1366 |
def GenerateZoomFunction(self, idx): |
|
1367 |
def ZoomFunction(event): |
|
1368 |
selected = self.TabsOpened.GetSelection() |
|
1369 |
if selected != -1: |
|
1370 |
window = self.TabsOpened.GetPage(selected) |
|
1371 |
window.SetScale(idx) |
|
1372 |
window.RefreshVisibleElements() |
|
1373 |
window.RefreshScrollBars() |
|
1374 |
event.Skip() |
|
1375 |
return ZoomFunction |
|
1376 |
||
1377 |
def OnResetPerspective(self, event): |
|
1378 |
self.ResetPerspective() |
|
1379 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1380 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1381 |
# Project Editor Panels Management Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1382 |
# ------------------------------------------------------------------------------- |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1383 |
|
814 | 1384 |
def OnPageDragged(self, event): |
1385 |
wx.CallAfter(self.RefreshTabCtrlEvent) |
|
1386 |
event.Skip() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1387 |
|
814 | 1388 |
def OnAllowNotebookDnD(self, event): |
1389 |
event.Allow() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1390 |
|
814 | 1391 |
def RefreshTabCtrlEvent(self): |
1392 |
auitabctrl = [] |
|
1393 |
for child in self.TabsOpened.GetChildren(): |
|
1394 |
if isinstance(child, wx.aui.AuiTabCtrl): |
|
1395 |
auitabctrl.append(child) |
|
1396 |
if child not in self.AuiTabCtrl: |
|
1397 |
child.Bind(wx.EVT_LEFT_DCLICK, self.GetTabsOpenedDClickFunction(child)) |
|
1398 |
self.AuiTabCtrl = auitabctrl |
|
1399 |
if self.TabsOpened.GetPageCount() == 0: |
|
1400 |
pane = self.AUIManager.GetPane(self.TabsOpened) |
|
1401 |
if pane.IsMaximized(): |
|
1402 |
self.AUIManager.RestorePane(pane) |
|
1403 |
self.AUIManager.Update() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1404 |
|
814 | 1405 |
def EnsureTabVisible(self, tab): |
1406 |
notebook = tab.GetParent() |
|
1407 |
notebook.SetSelection(notebook.GetPageIndex(tab)) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1408 |
|
814 | 1409 |
def OnPouSelectedChanging(self, event): |
989 | 1410 |
selected = self.TabsOpened.GetSelection() |
1411 |
if selected >= 0: |
|
1412 |
window = self.TabsOpened.GetPage(selected) |
|
1413 |
if not window.IsDebugging(): |
|
1414 |
window.ResetBuffer() |
|
814 | 1415 |
event.Skip() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1416 |
|
814 | 1417 |
def OnPouSelectedChanged(self, event): |
989 | 1418 |
selected = self.TabsOpened.GetSelection() |
1419 |
if selected >= 0: |
|
1420 |
window = self.TabsOpened.GetPage(selected) |
|
1421 |
tagname = window.GetTagName() |
|
1422 |
if not window.IsDebugging(): |
|
1158
193e6cd9010f
Fixed bug tabs selected cyclically when drag'n dropping variable into Editor
Laurent Bessard
parents:
1129
diff
changeset
|
1423 |
self.SelectProjectTreeItem(tagname) |
1233
5e6d0969bb5d
Fixed bugs in refresh of PouInstanceVariablesPanel
Laurent Bessard
parents:
1222
diff
changeset
|
1424 |
self.PouInstanceVariablesPanel.SetPouType(tagname) |
989 | 1425 |
window.RefreshView() |
1426 |
self.EnsureTabVisible(self.LibraryPanel) |
|
1427 |
else: |
|
1428 |
instance_path = window.GetInstancePath() |
|
1429 |
if tagname == "": |
|
1430 |
instance_path = instance_path.rsplit(".", 1)[0] |
|
1431 |
tagname = self.Controler.GetPouInstanceTagName(instance_path, self.EnableDebug) |
|
1432 |
self.EnsureTabVisible(self.DebugVariablePanel) |
|
1433 |
wx.CallAfter(self.PouInstanceVariablesPanel.SetPouType, tagname, instance_path) |
|
1434 |
wx.CallAfter(self._Refresh, FILEMENU, EDITMENU, DISPLAYMENU, EDITORTOOLBAR) |
|
814 | 1435 |
event.Skip() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1436 |
|
814 | 1437 |
def RefreshEditor(self): |
1438 |
selected = self.TabsOpened.GetSelection() |
|
1439 |
if selected >= 0: |
|
1440 |
window = self.TabsOpened.GetPage(selected) |
|
1441 |
tagname = window.GetTagName() |
|
1442 |
if not window.IsDebugging(): |
|
1443 |
self.SelectProjectTreeItem(tagname) |
|
1444 |
self.PouInstanceVariablesPanel.SetPouType(tagname) |
|
1445 |
else: |
|
1446 |
instance_path = window.GetInstancePath() |
|
1447 |
if tagname == "": |
|
1448 |
instance_path = instance_path.rsplit(".", 1)[0] |
|
1449 |
tagname = self.Controler.GetPouInstanceTagName(instance_path, self.EnableDebug) |
|
1450 |
self.PouInstanceVariablesPanel.SetPouType(tagname, instance_path) |
|
1451 |
for child in self.TabsOpened.GetChildren(): |
|
1452 |
if isinstance(child, wx.aui.AuiTabCtrl): |
|
1453 |
active_page = child.GetActivePage() |
|
1454 |
if active_page >= 0: |
|
1455 |
window = child.GetWindowFromIdx(active_page) |
|
1456 |
window.RefreshView() |
|
1457 |
self._Refresh(FILEMENU, EDITMENU, DISPLAYMENU, EDITORTOOLBAR) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1458 |
|
814 | 1459 |
def RefreshEditorNames(self, old_tagname, new_tagname): |
1460 |
for i in xrange(self.TabsOpened.GetPageCount()): |
|
1461 |
editor = self.TabsOpened.GetPage(i) |
|
1462 |
if editor.GetTagName() == old_tagname: |
|
1463 |
editor.SetTagName(new_tagname) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1464 |
|
814 | 1465 |
def IsOpened(self, tagname): |
1466 |
for idx in xrange(self.TabsOpened.GetPageCount()): |
|
1467 |
if self.TabsOpened.GetPage(idx).IsViewing(tagname): |
|
1468 |
return idx |
|
1469 |
return None |
|
1470 |
||
1471 |
def RefreshPageTitles(self): |
|
1472 |
for idx in xrange(self.TabsOpened.GetPageCount()): |
|
1473 |
window = self.TabsOpened.GetPage(idx) |
|
1474 |
icon = window.GetIcon() |
|
1475 |
if icon is not None: |
|
1476 |
self.SetPageBitmap(idx, icon) |
|
1477 |
self.TabsOpened.SetPageText(idx, window.GetTitle()) |
|
1478 |
||
1479 |
def GetTabsOpenedDClickFunction(self, tabctrl): |
|
1480 |
def OnTabsOpenedDClick(event): |
|
1481 |
pos = event.GetPosition() |
|
1482 |
if tabctrl.TabHitTest(pos.x, pos.y, None): |
|
1530
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1483 |
self.SwitchFullScrMode(event) |
814 | 1484 |
event.Skip() |
1485 |
return OnTabsOpenedDClick |
|
1486 |
||
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1739
diff
changeset
|
1487 |
def SwitchFullScrMode(self, evt): |
1530
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1488 |
pane = self.AUIManager.GetPane(self.TabsOpened) |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1489 |
if pane.IsMaximized(): |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1490 |
self.AUIManager.RestorePane(pane) |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1491 |
else: |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1492 |
self.AUIManager.MaximizePane(pane) |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1493 |
self.AUIManager.Update() |
24d8e8c233bd
Add hotkey (F12) for switching perspective.
Sergey Surkov <surkovsv93@gmail.com>
parents:
1514
diff
changeset
|
1494 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1495 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1496 |
# Types Tree Management Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
1497 |
# ------------------------------------------------------------------------------- |
814 | 1498 |
|
1499 |
def RefreshProjectTree(self): |
|
1105
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1500 |
# Extract current selected item tagname |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1501 |
selected = self.ProjectTree.GetSelection() |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1502 |
if selected is not None and selected.IsOk(): |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1503 |
item_infos = self.ProjectTree.GetPyData(selected) |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1504 |
tagname = item_infos.get("tagname", None) |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1505 |
else: |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1506 |
tagname = None |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1507 |
|
1105
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1508 |
# Refresh treectrl items according to project infos |
1884
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1509 |
if self.Controler: |
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1510 |
infos = self.Controler.GetProjectInfos() |
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1511 |
root = self.ProjectTree.GetRootItem() |
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1512 |
if root is None or not root.IsOk(): |
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1513 |
root = self.ProjectTree.AddRoot(infos["name"]) |
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1514 |
self.GenerateProjectTreeBranch(root, infos) |
48bd91d7a0ae
fix missing root in empty search results panel
Surkov Sergey <surkovsv93@gmail.com>
parents:
1881
diff
changeset
|
1515 |
self.ProjectTree.Expand(root) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1516 |
|
1105
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1517 |
# Select new item corresponding to previous selected item |
f0e5b475a074
Fixed bug when modifying ConfTreeNode IEC Channel
Laurent Bessard
parents:
1089
diff
changeset
|
1518 |
if tagname is not None: |
1158
193e6cd9010f
Fixed bug tabs selected cyclically when drag'n dropping variable into Editor
Laurent Bessard
parents:
1129
diff
changeset
|
1519 |
self.SelectProjectTreeItem(tagname) |
814 | 1520 |
|
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1521 |
def GenerateProjectTreeBranch(self, root, infos, item_alone=False): |
814 | 1522 |
to_delete = [] |
1523 |
item_name = infos["name"] |
|
1524 |
if infos["type"] in ITEMS_UNEDITABLE: |
|
1525 |
if len(infos["values"]) == 1: |
|
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1526 |
return self.GenerateProjectTreeBranch(root, infos["values"][0], True) |
814 | 1527 |
item_name = _(item_name) |
1528 |
self.ProjectTree.SetItemText(root, item_name) |
|
1529 |
self.ProjectTree.SetPyData(root, infos) |
|
1635
25e3bf6e193d
change white background for project tree element to transparent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1610
diff
changeset
|
1530 |
highlight_colours = self.Highlights.get(infos.get("tagname", None), (wx.Colour(255, 255, 255, 0), wx.BLACK)) |
1978
526013d2d462
#2579 On showing search result, text color of tree item is set to white. We need to change back color to show the result.
dporopat <denis.poropat@smarteh.si>
parents:
1948
diff
changeset
|
1531 |
self.ProjectTree.SetItemBackgroundColour(root, highlight_colours[0]) |
814 | 1532 |
self.ProjectTree.SetItemTextColour(root, highlight_colours[1]) |
1188
63afb5833bd8
Fixed bug two icons displayed for POU category item in Project Tree when adding a second POU
Laurent Bessard
parents:
1176
diff
changeset
|
1533 |
self.ProjectTree.SetItemExtraImage(root, None) |
814 | 1534 |
if infos["type"] == ITEM_POU: |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1535 |
self.ProjectTree.SetItemImage( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1536 |
root, self.TreeImageDict[self.Controler.GetPouBodyType(infos["name"])]) |
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1537 |
if item_alone: |
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1538 |
self.ProjectTree.SetItemExtraImage(root, self.Controler.GetPouType(infos["name"])) |
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
1539 |
elif "icon" in infos and infos["icon"] is not None: |
814 | 1540 |
icon_name = infos["icon"] |
1775
b45f2768fab1
clean-up: fix PEP8 E713 test for membership should be 'not in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1773
diff
changeset
|
1541 |
if icon_name not in self.TreeImageDict: |
814 | 1542 |
self.TreeImageDict[icon_name] = self.TreeImageList.Add(GetBitmap(icon_name)) |
1543 |
self.ProjectTree.SetItemImage(root, self.TreeImageDict[icon_name]) |
|
1763
bcc07ff2362c
clean-up: fix PEP8 W601 .has_key() is deprecated, use 'in'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1762
diff
changeset
|
1544 |
elif infos["type"] in self.TreeImageDict: |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1545 |
self.ProjectTree.SetItemImage(root, self.TreeImageDict[infos["type"]]) |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1546 |
|
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1547 |
item, root_cookie = self.ProjectTree.GetFirstChild(root) |
814 | 1548 |
for values in infos["values"]: |
1549 |
if values["type"] not in ITEMS_UNEDITABLE or len(values["values"]) > 0: |
|
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1550 |
if item is None or not item.IsOk(): |
814 | 1551 |
item = self.ProjectTree.AppendItem(root, "") |
1165
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1552 |
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
814 | 1553 |
self.GenerateProjectTreeBranch(item, values) |
1554 |
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
|
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1555 |
while item is not None and item.IsOk(): |
814 | 1556 |
to_delete.append(item) |
1557 |
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
|
1558 |
for item in to_delete: |
|
1559 |
self.ProjectTree.Delete(item) |
|
1560 |
||
1165
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1561 |
TagNamePartsItemTypes = { |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1562 |
"D": [ITEM_DATATYPE], |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1563 |
"P": [ITEM_POU], |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1564 |
"T": [ITEM_POU, ITEM_TRANSITION], |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1565 |
"A": [ITEM_POU, ITEM_ACTION], |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1566 |
"C": [ITEM_CONFIGURATION], |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1567 |
"R": [ITEM_CONFIGURATION, ITEM_RESOURCE]} |
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1568 |
|
814 | 1569 |
def SelectProjectTreeItem(self, tagname): |
1158
193e6cd9010f
Fixed bug tabs selected cyclically when drag'n dropping variable into Editor
Laurent Bessard
parents:
1129
diff
changeset
|
1570 |
result = False |
814 | 1571 |
if self.ProjectTree is not None: |
1572 |
root = self.ProjectTree.GetRootItem() |
|
1165
99972084890d
Fixed bugs with left panel CustomTreeCtrl on Windows
Laurent Bessard
parents:
1164
diff
changeset
|
1573 |
if root is not None and root.IsOk(): |
814 | 1574 |
words = tagname.split("::") |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1575 |
result = self.RecursiveProjectTreeItemSelection( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1576 |
root, zip(words[1:], self.TagNamePartsItemTypes.get(words[0], []))) |
1158
193e6cd9010f
Fixed bug tabs selected cyclically when drag'n dropping variable into Editor
Laurent Bessard
parents:
1129
diff
changeset
|
1577 |
return result |
814 | 1578 |
|
1579 |
def RecursiveProjectTreeItemSelection(self, root, items): |
|
1580 |
found = False |
|
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1581 |
item, root_cookie = self.ProjectTree.GetFirstChild(root) |
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1582 |
while item is not None and item.IsOk() and not found: |
814 | 1583 |
item_infos = self.ProjectTree.GetPyData(item) |
1584 |
if (item_infos["name"].split(":")[-1].strip(), item_infos["type"]) == items[0]: |
|
1585 |
if len(items) == 1: |
|
1586 |
self.SelectedItem = item |
|
1158
193e6cd9010f
Fixed bug tabs selected cyclically when drag'n dropping variable into Editor
Laurent Bessard
parents:
1129
diff
changeset
|
1587 |
self.ProjectTree.SelectItem(item) |
193e6cd9010f
Fixed bug tabs selected cyclically when drag'n dropping variable into Editor
Laurent Bessard
parents:
1129
diff
changeset
|
1588 |
self.ResetSelectedItem() |
814 | 1589 |
return True |
1590 |
else: |
|
1591 |
found = self.RecursiveProjectTreeItemSelection(item, items[1:]) |
|
1592 |
else: |
|
1593 |
found = self.RecursiveProjectTreeItemSelection(item, items) |
|
1594 |
item, root_cookie = self.ProjectTree.GetNextChild(root, root_cookie) |
|
1595 |
return found |
|
1596 |
||
1243
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1597 |
def ResetSelectedItem(self): |
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1598 |
self.SelectedItem = None |
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1599 |
|
814 | 1600 |
def OnProjectTreeBeginDrag(self, event): |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1601 |
selected_item = (self.SelectedItem |
1243
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1602 |
if self.SelectedItem is not None |
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1603 |
else event.GetItem()) |
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1604 |
if selected_item.IsOk() and self.ProjectTree.GetPyData(selected_item)["type"] == ITEM_POU: |
e77c95c4c7fc
Fixed bug when drag'n dropping POU from project tree and POU is selected
Laurent Bessard
parents:
1240
diff
changeset
|
1605 |
block_name = self.ProjectTree.GetItemText(selected_item) |
814 | 1606 |
block_type = self.Controler.GetPouType(block_name) |
1607 |
if block_type != "program": |
|
1608 |
data = wx.TextDataObject(str((block_name, block_type, ""))) |
|
1609 |
dragSource = wx.DropSource(self.ProjectTree) |
|
1610 |
dragSource.SetData(data) |
|
1611 |
dragSource.DoDragDrop() |
|
1612 |
self.ResetSelectedItem() |
|
1613 |
||
1614 |
def OnProjectTreeItemBeginEdit(self, event): |
|
1615 |
selected = event.GetItem() |
|
1616 |
if self.ProjectTree.GetPyData(selected)["type"] in ITEMS_UNEDITABLE: |
|
1617 |
event.Veto() |
|
1618 |
else: |
|
1619 |
event.Skip() |
|
1620 |
||
1621 |
def OnProjectTreeItemEndEdit(self, event): |
|
1622 |
message = None |
|
1623 |
abort = False |
|
1624 |
new_name = event.GetLabel() |
|
1625 |
if new_name != "": |
|
1626 |
if not TestIdentifier(new_name): |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1627 |
message = _("\"%s\" is not a valid identifier!") % new_name |
814 | 1628 |
elif new_name.upper() in IEC_KEYWORDS: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1629 |
message = _("\"%s\" is a keyword. It can't be used!") % new_name |
814 | 1630 |
else: |
1631 |
item = event.GetItem() |
|
1632 |
old_name = self.ProjectTree.GetItemText(item) |
|
1633 |
item_infos = self.ProjectTree.GetPyData(item) |
|
1634 |
if item_infos["type"] == ITEM_PROJECT: |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
1635 |
self.Controler.SetProjectProperties(name=new_name) |
814 | 1636 |
elif item_infos["type"] == ITEM_DATATYPE: |
1637 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectDataTypeNames() if name != old_name]: |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1638 |
message = _("\"%s\" data type already exists!") % new_name |
814 | 1639 |
abort = True |
1640 |
if not abort: |
|
1641 |
self.Controler.ChangeDataTypeName(old_name, new_name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1642 |
self.RefreshEditorNames(ComputeDataTypeName(old_name), |
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1643 |
ComputeDataTypeName(new_name)) |
814 | 1644 |
self.RefreshPageTitles() |
1645 |
elif item_infos["type"] == ITEM_POU: |
|
1646 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames() if name != old_name]: |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1647 |
message = _("\"%s\" pou already exists!") % new_name |
814 | 1648 |
abort = True |
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
1649 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1650 |
messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
814 | 1651 |
if messageDialog.ShowModal() == wx.ID_NO: |
1652 |
abort = True |
|
1653 |
messageDialog.Destroy() |
|
1654 |
if not abort: |
|
1655 |
self.Controler.ChangePouName(old_name, new_name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1656 |
self.RefreshEditorNames(ComputePouName(old_name), |
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1657 |
ComputePouName(new_name)) |
814 | 1658 |
self.RefreshLibraryPanel() |
1659 |
self.RefreshPageTitles() |
|
1660 |
elif item_infos["type"] == ITEM_TRANSITION: |
|
1610
31703a04789a
fix problem with SFC action/transition rename
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1556
diff
changeset
|
1661 |
pou_item = self.ProjectTree.GetItemParent(event.GetItem()) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1710
diff
changeset
|
1662 |
pou_name = self.ProjectTree.GetItemText(pou_item) |
814 | 1663 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1664 |
message = _("A POU named \"%s\" already exists!") % new_name |
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
1665 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames(pou_name) if name != old_name]: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1666 |
message = _("A variable with \"%s\" as name already exists in this pou!") % new_name |
814 | 1667 |
else: |
1668 |
words = item_infos["tagname"].split("::") |
|
1669 |
self.Controler.ChangePouTransitionName(words[1], old_name, new_name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1670 |
self.RefreshEditorNames(ComputePouTransitionName(words[1], old_name), |
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1671 |
ComputePouTransitionName(words[1], new_name)) |
814 | 1672 |
self.RefreshPageTitles() |
1673 |
elif item_infos["type"] == ITEM_ACTION: |
|
1610
31703a04789a
fix problem with SFC action/transition rename
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1556
diff
changeset
|
1674 |
pou_item = self.ProjectTree.GetItemParent(event.GetItem()) |
31703a04789a
fix problem with SFC action/transition rename
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1556
diff
changeset
|
1675 |
pou_name = self.ProjectTree.GetItemText(pou_item) |
814 | 1676 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1677 |
message = _("A POU named \"%s\" already exists!") % new_name |
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
1678 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames(pou_name) if name != old_name]: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1679 |
message = _("A variable with \"%s\" as name already exists in this pou!") % new_name |
814 | 1680 |
else: |
1681 |
words = item_infos["tagname"].split("::") |
|
1682 |
self.Controler.ChangePouActionName(words[1], old_name, new_name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1683 |
self.RefreshEditorNames(ComputePouActionName(words[1], old_name), |
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1684 |
ComputePouActionName(words[1], new_name)) |
814 | 1685 |
self.RefreshPageTitles() |
1686 |
elif item_infos["type"] == ITEM_CONFIGURATION: |
|
1687 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames() if name != old_name]: |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1688 |
message = _("\"%s\" config already exists!") % new_name |
814 | 1689 |
abort = True |
1690 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
|
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1691 |
messageDialog = wx.MessageDialog(self, _("There is a POU named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
814 | 1692 |
if messageDialog.ShowModal() == wx.ID_NO: |
1693 |
abort = True |
|
1694 |
messageDialog.Destroy() |
|
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
1695 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1696 |
messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
814 | 1697 |
if messageDialog.ShowModal() == wx.ID_NO: |
1698 |
abort = True |
|
1699 |
messageDialog.Destroy() |
|
1700 |
if not abort: |
|
1701 |
self.Controler.ChangeConfigurationName(old_name, new_name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1702 |
self.RefreshEditorNames(ComputeConfigurationName(old_name), |
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1703 |
ComputeConfigurationName(new_name)) |
814 | 1704 |
self.RefreshPageTitles() |
1705 |
elif item_infos["type"] == ITEM_RESOURCE: |
|
1706 |
if new_name.upper() in [name.upper() for name in self.Controler.GetProjectConfigNames()]: |
|
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1733
diff
changeset
|
1707 |
message = _("\"%s\" config already exists!") % new_name |
814 | 1708 |
abort = True |
1709 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouNames()]: |
|
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1710 |
messageDialog = wx.MessageDialog(self, _("There is a POU named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
814 | 1711 |
if messageDialog.ShowModal() == wx.ID_NO: |
1712 |
abort = True |
|
1713 |
messageDialog.Destroy() |
|
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
1714 |
elif new_name.upper() in [name.upper() for name in self.Controler.GetProjectPouVariableNames()]: |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
1715 |
messageDialog = wx.MessageDialog(self, _("A POU has an element named \"%s\". This could cause a conflict. Do you wish to continue?") % new_name, _("Error"), wx.YES_NO | wx.ICON_QUESTION) |
814 | 1716 |
if messageDialog.ShowModal() == wx.ID_NO: |
1717 |
abort = True |
|
1718 |
messageDialog.Destroy() |
|
1719 |
if not abort: |
|
1720 |
words = item_infos["tagname"].split("::") |
|
1721 |
self.Controler.ChangeConfigurationResourceName(words[1], old_name, new_name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1722 |
self.RefreshEditorNames(ComputeConfigurationResourceName(words[1], old_name), |
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
1723 |
ComputeConfigurationResourceName(words[1], new_name)) |
814 | 1724 |
self.RefreshPageTitles() |
1725 |
if message or abort: |
|
1726 |
if message: |
|
1727 |
self.ShowErrorMessage(message) |
|
1728 |
event.Veto() |
|
1729 |
else: |
|
1730 |
wx.CallAfter(self.RefreshProjectTree) |
|
1731 |
self.RefreshEditor() |
|
1732 |
self._Refresh(TITLE, FILEMENU, EDITMENU) |
|
1733 |
event.Skip() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1734 |
|
814 | 1735 |
def OnProjectTreeItemActivated(self, event): |
1736 |
selected = event.GetItem() |
|
1737 |
item_infos = self.ProjectTree.GetPyData(selected) |
|
1738 |
if item_infos["type"] == ITEM_PROJECT: |
|
1739 |
self.EditProjectSettings() |
|
1740 |
else: |
|
1741 |
if item_infos["type"] in [ITEM_DATATYPE, ITEM_POU, |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1742 |
ITEM_CONFIGURATION, ITEM_RESOURCE, |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1743 |
ITEM_TRANSITION, ITEM_ACTION]: |
814 | 1744 |
self.EditProjectElement(item_infos["type"], item_infos["tagname"]) |
1745 |
event.Skip() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1746 |
|
814 | 1747 |
def ProjectTreeItemSelect(self, select_item): |
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1748 |
if select_item is not None and select_item.IsOk(): |
1112
ff3fcad17b47
Fixed bug when selecting item in ProjectTree on Linux
Laurent Bessard
parents:
1106
diff
changeset
|
1749 |
item_infos = self.ProjectTree.GetPyData(select_item) |
ff3fcad17b47
Fixed bug when selecting item in ProjectTree on Linux
Laurent Bessard
parents:
1106
diff
changeset
|
1750 |
if item_infos["type"] in [ITEM_DATATYPE, ITEM_POU, |
ff3fcad17b47
Fixed bug when selecting item in ProjectTree on Linux
Laurent Bessard
parents:
1106
diff
changeset
|
1751 |
ITEM_CONFIGURATION, ITEM_RESOURCE, |
ff3fcad17b47
Fixed bug when selecting item in ProjectTree on Linux
Laurent Bessard
parents:
1106
diff
changeset
|
1752 |
ITEM_TRANSITION, ITEM_ACTION]: |
ff3fcad17b47
Fixed bug when selecting item in ProjectTree on Linux
Laurent Bessard
parents:
1106
diff
changeset
|
1753 |
self.EditProjectElement(item_infos["type"], item_infos["tagname"], True) |
ff3fcad17b47
Fixed bug when selecting item in ProjectTree on Linux
Laurent Bessard
parents:
1106
diff
changeset
|
1754 |
self.PouInstanceVariablesPanel.SetPouType(item_infos["tagname"]) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1755 |
|
814 | 1756 |
def OnProjectTreeLeftUp(self, event): |
1757 |
if self.SelectedItem is not None: |
|
1758 |
self.ProjectTree.SelectItem(self.SelectedItem) |
|
1759 |
self.ProjectTreeItemSelect(self.SelectedItem) |
|
1240
ceaf9b4c0f86
Fixed bug when drag'n dropping POU from project tree, POU editor is selected if open
Laurent Bessard
parents:
1233
diff
changeset
|
1760 |
self.ResetSelectedItem() |
814 | 1761 |
event.Skip() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1762 |
|
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1763 |
def OnProjectTreeMotion(self, event): |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1764 |
if not event.Dragging(): |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1765 |
pt = wx.Point(event.GetX(), event.GetY()) |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1766 |
item, flags = self.ProjectTree.HitTest(pt) |
1164
8fd44bc05aae
Added extra icon in left panel tree for indicating Pou type (function, functionBlock, or program) when alone
Laurent Bessard
parents:
1159
diff
changeset
|
1767 |
if item is not None and item.IsOk() and flags & wx.TREE_HITTEST_ONITEMLABEL: |
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1768 |
item_infos = self.ProjectTree.GetPyData(item) |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1769 |
if item != self.LastToolTipItem and self.LastToolTipItem is not None: |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1770 |
self.ProjectTree.SetToolTip(None) |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1771 |
self.LastToolTipItem = None |
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
1772 |
if self.LastToolTipItem != item and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1765
diff
changeset
|
1773 |
item_infos["type"] in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]: |
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1774 |
bodytype = self.Controler.GetEditedElementBodyType( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1855
diff
changeset
|
1775 |
item_infos["tagname"]) |
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1776 |
if item_infos["type"] == ITEM_POU: |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1777 |
block_type = { |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1778 |
"program": _("Program"), |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1779 |
"functionBlock": _("Function Block"), |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1780 |
"function": _("Function") |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1781 |
}[self.Controler.GetPouType(item_infos["name"])] |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1782 |
elif item_infos["type"] == ITEM_TRANSITION: |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1783 |
block_type = "Transition" |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1784 |
else: |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1785 |
block_type = "Action" |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1786 |
self.LastToolTipItem = item |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1787 |
wx.CallAfter(self.ProjectTree.SetToolTipString, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1788 |
"%s : %s : %s" % ( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1789 |
block_type, bodytype, item_infos["name"])) |
1106
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1790 |
elif self.LastToolTipItem is not None: |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1791 |
self.ProjectTree.SetToolTip(None) |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1792 |
self.LastToolTipItem = None |
843d181f73b4
Added tooltip in ProjectTree when mouse over POU
Laurent Bessard
parents:
1105
diff
changeset
|
1793 |
event.Skip() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1794 |
|
814 | 1795 |
def OnProjectTreeItemChanging(self, event): |
1796 |
if self.ProjectTree.GetPyData(event.GetItem())["type"] not in ITEMS_UNEDITABLE and self.SelectedItem is None: |
|
1797 |
self.SelectedItem = event.GetItem() |
|
1798 |
event.Veto() |
|
1799 |
else: |
|
1800 |
event.Skip() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1801 |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
1802 |
def EditProjectElement(self, element, tagname, onlyopened=False): |
814 | 1803 |
openedidx = self.IsOpened(tagname) |
1804 |
if openedidx is not None: |
|
1805 |
old_selected = self.TabsOpened.GetSelection() |
|
1806 |
if old_selected != openedidx: |
|
1807 |
if old_selected >= 0: |
|
1808 |
self.TabsOpened.GetPage(old_selected).ResetBuffer() |
|
1809 |
self.TabsOpened.SetSelection(openedidx) |
|
1810 |
self._Refresh(FILEMENU, EDITMENU, EDITORTOOLBAR, PAGETITLES) |
|
1811 |
elif not onlyopened: |
|
870
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1812 |
if isinstance(element, EditorPanel): |
814 | 1813 |
new_window = element |
1814 |
self.AddPage(element, "") |
|
870
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1815 |
elif self.Controler.GetEditedElement(tagname) is not None: |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1816 |
new_window = None |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1817 |
if element == ITEM_CONFIGURATION: |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1818 |
new_window = ConfigurationEditor(self.TabsOpened, tagname, self, self.Controler) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1819 |
new_window.SetIcon(GetBitmap("CONFIGURATION")) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1820 |
self.AddPage(new_window, "") |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1821 |
elif element == ITEM_RESOURCE: |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1822 |
new_window = ResourceEditor(self.TabsOpened, tagname, self, self.Controler) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1823 |
new_window.SetIcon(GetBitmap("RESOURCE")) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1824 |
self.AddPage(new_window, "") |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1825 |
elif element in [ITEM_POU, ITEM_TRANSITION, ITEM_ACTION]: |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1826 |
bodytype = self.Controler.GetEditedElementBodyType(tagname) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1827 |
if bodytype == "FBD": |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1828 |
new_window = Viewer(self.TabsOpened, tagname, self, self.Controler) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1829 |
new_window.RefreshScaling(False) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1830 |
elif bodytype == "LD": |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1831 |
new_window = LD_Viewer(self.TabsOpened, tagname, self, self.Controler) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1832 |
new_window.RefreshScaling(False) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1833 |
elif bodytype == "SFC": |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1834 |
new_window = SFC_Viewer(self.TabsOpened, tagname, self, self.Controler) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1835 |
new_window.RefreshScaling(False) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1836 |
else: |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1837 |
new_window = TextViewer(self.TabsOpened, tagname, self, self.Controler) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1838 |
new_window.SetTextSyntax(bodytype) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1839 |
if bodytype == "IL": |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1840 |
new_window.SetKeywords(IL_KEYWORDS) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1841 |
else: |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1842 |
new_window.SetKeywords(ST_KEYWORDS) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1843 |
if element == ITEM_POU: |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1844 |
pou_type = self.Controler.GetEditedElementType(tagname)[1].upper() |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1845 |
icon = GetBitmap(pou_type, bodytype) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1846 |
elif element == ITEM_TRANSITION: |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1847 |
icon = GetBitmap("TRANSITION", bodytype) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1848 |
elif element == ITEM_ACTION: |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1849 |
icon = GetBitmap("ACTION", bodytype) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1850 |
new_window.SetIcon(icon) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1851 |
self.AddPage(new_window, "") |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1852 |
elif element == ITEM_DATATYPE: |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1853 |
new_window = DataTypeEditor(self.TabsOpened, tagname, self, self.Controler) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1854 |
new_window.SetIcon(GetBitmap("DATATYPE")) |
61b32521442e
Fix bug in RestoreLayout when previously opened tab no more exist in project
Laurent Bessard
parents:
849
diff
changeset
|
1855 |
self.AddPage(new_window, "") |
814 | 1856 |
if new_window is not None: |
1857 |
openedidx = self.IsOpened(tagname) |
|
1858 |
old_selected = self.TabsOpened.GetSelection() |
|
1859 |
if old_selected != openedidx: |
|
1860 |
if old_selected >= 0: |
|
1861 |
self.TabsOpened.GetPage(old_selected).ResetBuffer() |
|
1862 |
for i in xrange(self.TabsOpened.GetPageCount()): |
|
1863 |
window = self.TabsOpened.GetPage(i) |
|
1864 |
if window == new_window: |
|
1865 |
self.TabsOpened.SetSelection(i) |
|
1866 |
window.SetFocus() |
|
1867 |
self.RefreshPageTitles() |
|
1868 |
return new_window |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1869 |
|
814 | 1870 |
def OnProjectTreeRightUp(self, event): |
1240
ceaf9b4c0f86
Fixed bug when drag'n dropping POU from project tree, POU editor is selected if open
Laurent Bessard
parents:
1233
diff
changeset
|
1871 |
item = event.GetItem() |
814 | 1872 |
self.ProjectTree.SelectItem(item) |
1873 |
self.ProjectTreeItemSelect(item) |
|
1874 |
name = self.ProjectTree.GetItemText(item) |
|
1875 |
item_infos = self.ProjectTree.GetPyData(item) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1876 |
|
814 | 1877 |
menu = None |
1878 |
if item_infos["type"] in ITEMS_UNEDITABLE + [ITEM_PROJECT]: |
|
1879 |
if item_infos["type"] == ITEM_PROJECT: |
|
1880 |
name = "Project" |
|
1881 |
else: |
|
1882 |
name = UNEDITABLE_NAMES_DICT[name] |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1883 |
|
814 | 1884 |
if name == "Data Types": |
1885 |
menu = wx.Menu(title='') |
|
1886 |
new_id = wx.NewId() |
|
1887 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add DataType")) |
|
1888 |
self.Bind(wx.EVT_MENU, self.OnAddDataTypeMenu, id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1889 |
|
814 | 1890 |
elif name in ["Functions", "Function Blocks", "Programs", "Project"]: |
1891 |
menu = wx.Menu(title='') |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1892 |
|
814 | 1893 |
if name != "Project": |
1894 |
new_id = wx.NewId() |
|
1895 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add POU")) |
|
1739
ec153828ded2
clean-up: fix PEP8 E203 whitespace before ':' and whitespace before ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
1896 |
self.Bind(wx.EVT_MENU, self.GenerateAddPouFunction({"Functions": "function", "Function Blocks": "functionBlock", "Programs": "program"}[name]), id=new_id) |
814 | 1897 |
|
1898 |
new_id = wx.NewId() |
|
1899 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Paste POU")) |
|
1900 |
self.Bind(wx.EVT_MENU, self.OnPastePou, id=new_id) |
|
1901 |
if self.GetCopyBuffer() is None: |
|
1902 |
menu.Enable(new_id, False) |
|
1903 |
||
1904 |
elif name == "Configurations": |
|
1905 |
menu = wx.Menu(title='') |
|
1906 |
new_id = wx.NewId() |
|
1907 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Configuration")) |
|
1908 |
self.Bind(wx.EVT_MENU, self.OnAddConfigurationMenu, id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1909 |
|
814 | 1910 |
elif name == "Transitions": |
1911 |
menu = wx.Menu(title='') |
|
1912 |
new_id = wx.NewId() |
|
1913 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Transition")) |
|
1010
44c3cafef436
Fixed typo in IDEFrame OnProjectTreeRightUp method
Laurent Bessard
parents:
999
diff
changeset
|
1914 |
parent = self.ProjectTree.GetItemParent(item) |
44c3cafef436
Fixed typo in IDEFrame OnProjectTreeRightUp method
Laurent Bessard
parents:
999
diff
changeset
|
1915 |
parent_type = self.ProjectTree.GetPyData(parent)["type"] |
814 | 1916 |
while parent_type != ITEM_POU: |
1917 |
parent = self.ProjectTree.GetItemParent(parent) |
|
1918 |
parent_type = self.ProjectTree.GetPyData(parent)["type"] |
|
1919 |
self.Bind(wx.EVT_MENU, self.GenerateAddTransitionFunction(self.ProjectTree.GetItemText(parent)), id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1920 |
|
814 | 1921 |
elif name == "Actions": |
1922 |
menu = wx.Menu(title='') |
|
1923 |
new_id = wx.NewId() |
|
1924 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Action")) |
|
1925 |
parent = self.ProjectTree.GetItemParent(item) |
|
1926 |
parent_type = self.ProjectTree.GetPyData(parent)["type"] |
|
1927 |
while parent_type != ITEM_POU: |
|
1928 |
parent = self.ProjectTree.GetItemParent(parent) |
|
1929 |
parent_type = self.ProjectTree.GetPyData(parent)["type"] |
|
1930 |
self.Bind(wx.EVT_MENU, self.GenerateAddActionFunction(self.ProjectTree.GetItemText(parent)), id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1931 |
|
814 | 1932 |
elif name == "Resources": |
1933 |
menu = wx.Menu(title='') |
|
1934 |
new_id = wx.NewId() |
|
1935 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Resource")) |
|
1936 |
parent = self.ProjectTree.GetItemParent(item) |
|
1937 |
parent_type = self.ProjectTree.GetPyData(parent)["type"] |
|
1938 |
while parent_type not in [ITEM_CONFIGURATION, ITEM_PROJECT]: |
|
1939 |
parent = self.ProjectTree.GetItemParent(parent) |
|
1940 |
parent_type = self.ProjectTree.GetPyData(parent)["type"] |
|
1024
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1941 |
parent_name = None |
814 | 1942 |
if parent_type == ITEM_PROJECT: |
1024
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1943 |
config_names = self.Controler.GetProjectConfigNames() |
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1944 |
if len(config_names) > 0: |
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1945 |
parent_name = config_names[0] |
814 | 1946 |
else: |
1947 |
parent_name = self.ProjectTree.GetItemText(parent) |
|
1024
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1948 |
if parent_name is not None: |
626de4ff4bdc
Fixed resource editing, removing definition of more than one resource and deletion of last resource defined
Laurent Bessard
parents:
1019
diff
changeset
|
1949 |
self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(parent_name), id=new_id) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1950 |
|
814 | 1951 |
else: |
1952 |
if item_infos["type"] == ITEM_POU: |
|
1953 |
menu = wx.Menu(title='') |
|
1954 |
if self.Controler.GetPouBodyType(name) == "SFC": |
|
1955 |
new_id = wx.NewId() |
|
1956 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Transition")) |
|
1957 |
self.Bind(wx.EVT_MENU, self.GenerateAddTransitionFunction(name), id=new_id) |
|
1958 |
new_id = wx.NewId() |
|
1959 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Action")) |
|
1960 |
self.Bind(wx.EVT_MENU, self.GenerateAddActionFunction(name), id=new_id) |
|
1961 |
menu.AppendSeparator() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1962 |
|
814 | 1963 |
new_id = wx.NewId() |
1964 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Copy POU")) |
|
1965 |
self.Bind(wx.EVT_MENU, self.OnCopyPou, id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1966 |
|
814 | 1967 |
pou_type = self.Controler.GetPouType(name) |
1968 |
if pou_type in ["function", "functionBlock"]: |
|
1969 |
change_menu = wx.Menu(title='') |
|
1970 |
if pou_type == "function": |
|
1971 |
new_id = wx.NewId() |
|
1972 |
AppendMenu(change_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Function Block")) |
|
1973 |
self.Bind(wx.EVT_MENU, self.GenerateChangePouTypeFunction(name, "functionBlock"), id=new_id) |
|
1974 |
new_id = wx.NewId() |
|
1975 |
AppendMenu(change_menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Program")) |
|
1976 |
self.Bind(wx.EVT_MENU, self.GenerateChangePouTypeFunction(name, "program"), id=new_id) |
|
1977 |
menu.AppendMenu(wx.NewId(), _("Change POU Type To"), change_menu) |
|
1978 |
new_id = wx.NewId() |
|
1979 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Rename")) |
|
1980 |
self.Bind(wx.EVT_MENU, self.OnRenamePouMenu, id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1981 |
|
814 | 1982 |
elif item_infos["type"] == ITEM_CONFIGURATION: |
1983 |
menu = wx.Menu(title='') |
|
1984 |
new_id = wx.NewId() |
|
1985 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Add Resource")) |
|
1986 |
self.Bind(wx.EVT_MENU, self.GenerateAddResourceFunction(name), id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1987 |
|
814 | 1988 |
elif item_infos["type"] in [ITEM_DATATYPE, ITEM_TRANSITION, ITEM_ACTION, ITEM_RESOURCE]: |
1989 |
menu = wx.Menu(title='') |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1990 |
|
814 | 1991 |
if menu is not None: |
1992 |
new_id = wx.NewId() |
|
1993 |
AppendMenu(menu, help='', id=new_id, kind=wx.ITEM_NORMAL, text=_("Delete")) |
|
1994 |
self.Bind(wx.EVT_MENU, self.OnDeleteMenu, id=new_id) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1995 |
|
814 | 1996 |
if menu is not None: |
1480
79e54c5dead5
fix issue, then it wasn't possible to remove functional blocks from
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1408
diff
changeset
|
1997 |
self.FindFocus().PopupMenu(menu) |
814 | 1998 |
menu.Destroy() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
1999 |
|
1240
ceaf9b4c0f86
Fixed bug when drag'n dropping POU from project tree, POU editor is selected if open
Laurent Bessard
parents:
1233
diff
changeset
|
2000 |
self.ResetSelectedItem() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2001 |
|
814 | 2002 |
event.Skip() |
2003 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2004 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2005 |
# Instances Tree Management Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2006 |
# ------------------------------------------------------------------------------- |
814 | 2007 |
|
2008 |
def GetTreeImage(self, var_class): |
|
2009 |
return self.TreeImageDict[var_class] |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2010 |
|
814 | 2011 |
def RefreshPouInstanceVariablesPanel(self): |
2012 |
self.PouInstanceVariablesPanel.RefreshView() |
|
2013 |
||
2014 |
def OpenDebugViewer(self, instance_category, instance_path, instance_type): |
|
2015 |
openedidx = self.IsOpened(instance_path) |
|
930
4be515ac635e
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
916
diff
changeset
|
2016 |
new_window = None |
814 | 2017 |
if openedidx is not None: |
2018 |
old_selected = self.TabsOpened.GetSelection() |
|
2019 |
if old_selected != openedidx: |
|
2020 |
if old_selected >= 0: |
|
2021 |
self.TabsOpened.GetPage(old_selected).ResetBuffer() |
|
2022 |
self.TabsOpened.SetSelection(openedidx) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2023 |
|
814 | 2024 |
elif instance_category in ITEMS_VARIABLE: |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
885
diff
changeset
|
2025 |
if self.Controler.IsNumType(instance_type, True): |
1364
e9e17d3b2849
Remove old debug panels and viewers not using matplotlib
Laurent Bessard
parents:
1362
diff
changeset
|
2026 |
self.AddDebugVariable(instance_path, True) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2027 |
|
814 | 2028 |
else: |
2029 |
bodytype = self.Controler.GetEditedElementBodyType(instance_type, True) |
|
2030 |
if bodytype == "FBD": |
|
2031 |
new_window = Viewer(self.TabsOpened, instance_type, self, self.Controler, True, instance_path) |
|
2032 |
new_window.RefreshScaling(False) |
|
2033 |
elif bodytype == "LD": |
|
2034 |
new_window = LD_Viewer(self.TabsOpened, instance_type, self, self.Controler, True, instance_path) |
|
2035 |
new_window.RefreshScaling(False) |
|
2036 |
elif bodytype == "SFC": |
|
2037 |
new_window = SFC_Viewer(self.TabsOpened, instance_type, self, self.Controler, True, instance_path) |
|
2038 |
new_window.RefreshScaling(False) |
|
2039 |
else: |
|
2040 |
new_window = TextViewer(self.TabsOpened, instance_type, self, self.Controler, True, instance_path) |
|
2041 |
new_window.SetTextSyntax(bodytype) |
|
2042 |
if bodytype == "IL": |
|
2043 |
new_window.SetKeywords(IL_KEYWORDS) |
|
2044 |
else: |
|
2045 |
new_window.SetKeywords(ST_KEYWORDS) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2046 |
|
814 | 2047 |
if new_window is not None: |
2048 |
if instance_category in [ITEM_FUNCTIONBLOCK, ITEM_PROGRAM]: |
|
2049 |
pou_type = self.Controler.GetEditedElementType(instance_type, True)[1].upper() |
|
2050 |
icon = GetBitmap(pou_type, bodytype) |
|
2051 |
elif instance_category == ITEM_TRANSITION: |
|
2052 |
icon = GetBitmap("TRANSITION", bodytype) |
|
2053 |
elif instance_category == ITEM_ACTION: |
|
2054 |
icon = GetBitmap("ACTION", bodytype) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2055 |
|
885
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
870
diff
changeset
|
2056 |
if new_window is not None: |
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
870
diff
changeset
|
2057 |
new_window.SetIcon(icon) |
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
870
diff
changeset
|
2058 |
self.AddPage(new_window, "") |
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
870
diff
changeset
|
2059 |
new_window.RefreshView() |
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
870
diff
changeset
|
2060 |
new_window.SetFocus() |
fc91d3718b74
Fix bug multiple graph viewer tab displaying values of the same variable can be opened
Laurent Bessard
parents:
870
diff
changeset
|
2061 |
self.RefreshPageTitles() |
814 | 2062 |
return new_window |
2063 |
||
2064 |
def ResetGraphicViewers(self): |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
885
diff
changeset
|
2065 |
if self.EnableDebug: |
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
885
diff
changeset
|
2066 |
self.DebugVariablePanel.ResetGraphicsValues() |
814 | 2067 |
|
2068 |
def CloseObsoleteDebugTabs(self): |
|
2069 |
if self.EnableDebug: |
|
2070 |
idxs = range(self.TabsOpened.GetPageCount()) |
|
2071 |
idxs.reverse() |
|
2072 |
for idx in idxs: |
|
2073 |
editor = self.TabsOpened.GetPage(idx) |
|
1364
e9e17d3b2849
Remove old debug panels and viewers not using matplotlib
Laurent Bessard
parents:
1362
diff
changeset
|
2074 |
if isinstance(editor, Viewer) and editor.IsDebugging(): |
814 | 2075 |
instance_infos = self.Controler.GetInstanceInfos(editor.GetInstancePath(), self.EnableDebug) |
2076 |
if instance_infos is None: |
|
2077 |
self.TabsOpened.DeletePage(idx) |
|
2078 |
else: |
|
1176
f4b434672204
Moved and rewrote DebugViewer and DebusDataConsumer classes
Laurent Bessard
parents:
1171
diff
changeset
|
2079 |
editor.SubscribeAllDataConsumers() |
1710
953ceea2573e
fix bug with TextViewer instance in debug mode, appears after transferring new program on PLC
Surkov Sergey <surkovsv93@gmail.com>
parents:
1708
diff
changeset
|
2080 |
elif editor.IsDebugging() and hasattr(editor, 'SubscribeAllDataConsumers'): |
1176
f4b434672204
Moved and rewrote DebugViewer and DebusDataConsumer classes
Laurent Bessard
parents:
1171
diff
changeset
|
2081 |
editor.SubscribeAllDataConsumers() |
1207 | 2082 |
self.DebugVariablePanel.SubscribeAllDataConsumers() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2083 |
|
1214
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1207
diff
changeset
|
2084 |
def AddDebugVariable(self, iec_path, force=False, graph=False): |
814 | 2085 |
if self.EnableDebug: |
1214
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1207
diff
changeset
|
2086 |
self.DebugVariablePanel.InsertValue(iec_path, force=force, graph=graph) |
814 | 2087 |
self.EnsureTabVisible(self.DebugVariablePanel) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2088 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2089 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2090 |
# Library Panel Management Function |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2091 |
# ------------------------------------------------------------------------------- |
814 | 2092 |
|
2093 |
def RefreshLibraryPanel(self): |
|
2094 |
self.LibraryPanel.RefreshTree() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2095 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2096 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2097 |
# ToolBars Management Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2098 |
# ------------------------------------------------------------------------------- |
814 | 2099 |
|
2100 |
def AddToMenuToolBar(self, items): |
|
2101 |
MenuToolBar = self.Panes["MenuToolBar"] |
|
2102 |
if MenuToolBar.GetToolsCount() > 0: |
|
2103 |
MenuToolBar.AddSeparator() |
|
2104 |
for toolbar_item in items: |
|
2105 |
if toolbar_item is None: |
|
2106 |
MenuToolBar.AddSeparator() |
|
2107 |
else: |
|
2108 |
id, bitmap, help, callback = toolbar_item |
|
2109 |
MenuToolBar.AddSimpleTool(id=id, shortHelpString=help, bitmap=GetBitmap(bitmap)) |
|
2110 |
if callback is not None: |
|
2111 |
self.Bind(wx.EVT_TOOL, callback, id=id) |
|
2112 |
MenuToolBar.Realize() |
|
2113 |
self.AUIManager.GetPane("MenuToolBar").BestSize(MenuToolBar.GetBestSize()) |
|
2114 |
||
2115 |
def ResetEditorToolBar(self): |
|
2116 |
EditorToolBar = self.Panes["EditorToolBar"] |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2117 |
|
814 | 2118 |
for item in self.CurrentEditorToolBar: |
2177
10aa87518401
Drop support for wxPython 2.6 and below
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2169
diff
changeset
|
2119 |
self.Unbind(wx.EVT_MENU, id=item) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2120 |
|
814 | 2121 |
if EditorToolBar: |
2122 |
EditorToolBar.DeleteTool(item) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2123 |
|
814 | 2124 |
if EditorToolBar: |
2125 |
EditorToolBar.Realize() |
|
2126 |
self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize()) |
|
2127 |
self.AUIManager.GetPane("EditorToolBar").Hide() |
|
2128 |
self.AUIManager.Update() |
|
2129 |
||
2130 |
def RefreshEditorToolBar(self): |
|
2131 |
selected = self.TabsOpened.GetSelection() |
|
2132 |
menu = None |
|
2133 |
if selected != -1: |
|
2134 |
window = self.TabsOpened.GetPage(selected) |
|
1364
e9e17d3b2849
Remove old debug panels and viewers not using matplotlib
Laurent Bessard
parents:
1362
diff
changeset
|
2135 |
if isinstance(window, (Viewer, TextViewer)): |
814 | 2136 |
if not window.IsDebugging(): |
2137 |
menu = self.Controler.GetEditedElementBodyType(window.GetTagName()) |
|
2138 |
else: |
|
2139 |
menu = "debug" |
|
2140 |
if menu is not None and menu != self.CurrentMenu: |
|
2141 |
self.ResetEditorToolBar() |
|
2142 |
self.CurrentMenu = menu |
|
2143 |
self.CurrentEditorToolBar = [] |
|
2144 |
EditorToolBar = self.Panes["EditorToolBar"] |
|
2145 |
if EditorToolBar: |
|
2146 |
for radio, modes, id, method, picture, help in EditorToolBarItems[menu]: |
|
2147 |
if modes & self.DrawingMode: |
|
2148 |
if radio or self.DrawingMode == FREEDRAWING_MODE: |
|
2149 |
EditorToolBar.AddRadioTool(id, GetBitmap(picture), wx.NullBitmap, help) |
|
2150 |
else: |
|
2151 |
EditorToolBar.AddSimpleTool(id, GetBitmap(picture), help) |
|
2152 |
self.Bind(wx.EVT_MENU, getattr(self, method), id=id) |
|
2153 |
self.CurrentEditorToolBar.append(id) |
|
2154 |
EditorToolBar.Realize() |
|
2155 |
self.AUIManager.GetPane("EditorToolBar").BestSize(EditorToolBar.GetBestSize()) |
|
2156 |
self.AUIManager.GetPane("EditorToolBar").Show() |
|
2157 |
self.AUIManager.Update() |
|
2158 |
elif menu is None: |
|
2159 |
self.ResetEditorToolBar() |
|
2160 |
self.CurrentMenu = menu |
|
2161 |
self.ResetCurrentMode() |
|
2162 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2163 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2164 |
# EditorToolBar Items Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2165 |
# ------------------------------------------------------------------------------- |
814 | 2166 |
|
2167 |
def ResetCurrentMode(self): |
|
2168 |
selected = self.TabsOpened.GetSelection() |
|
2169 |
if selected != -1: |
|
2170 |
window = self.TabsOpened.GetPage(selected) |
|
2171 |
window.SetMode(MODE_SELECTION) |
|
2172 |
EditorToolBar = self.Panes["EditorToolBar"] |
|
2173 |
if EditorToolBar: |
|
2174 |
EditorToolBar.ToggleTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION, False) |
|
2175 |
EditorToolBar.ToggleTool(ID_PLCOPENEDITOREDITORTOOLBARSELECTION, True) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2176 |
|
814 | 2177 |
def ResetToolToggle(self, id): |
2178 |
tool = self.Panes["EditorToolBar"].FindById(id) |
|
2179 |
tool.SetToggle(False) |
|
2180 |
||
2181 |
def OnSelectionTool(self, event): |
|
2182 |
selected = self.TabsOpened.GetSelection() |
|
2183 |
if selected != -1: |
|
2184 |
self.TabsOpened.GetPage(selected).SetMode(MODE_SELECTION) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2185 |
|
814 | 2186 |
def OnMotionTool(self, event): |
2187 |
selected = self.TabsOpened.GetSelection() |
|
2188 |
if selected != -1: |
|
2189 |
self.TabsOpened.GetPage(selected).SetMode(MODE_MOTION) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2190 |
|
814 | 2191 |
def OnCommentTool(self, event): |
2192 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARCOMMENT) |
|
2193 |
selected = self.TabsOpened.GetSelection() |
|
2194 |
if selected != -1: |
|
2195 |
self.TabsOpened.GetPage(selected).SetMode(MODE_COMMENT) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2196 |
|
814 | 2197 |
def OnVariableTool(self, event): |
2198 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARVARIABLE) |
|
2199 |
selected = self.TabsOpened.GetSelection() |
|
2200 |
if selected != -1: |
|
2201 |
self.TabsOpened.GetPage(selected).SetMode(MODE_VARIABLE) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2202 |
|
814 | 2203 |
def OnBlockTool(self, event): |
2204 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARBLOCK) |
|
2205 |
selected = self.TabsOpened.GetSelection() |
|
2206 |
if selected != -1: |
|
2207 |
self.TabsOpened.GetPage(selected).SetMode(MODE_BLOCK) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2208 |
|
814 | 2209 |
def OnConnectionTool(self, event): |
2210 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARCONNECTION) |
|
2211 |
selected = self.TabsOpened.GetSelection() |
|
2212 |
if selected != -1: |
|
2213 |
self.TabsOpened.GetPage(selected).SetMode(MODE_CONNECTION) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2214 |
|
814 | 2215 |
def OnPowerRailTool(self, event): |
2216 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARPOWERRAIL) |
|
2217 |
selected = self.TabsOpened.GetSelection() |
|
2218 |
if selected != -1: |
|
2219 |
self.TabsOpened.GetPage(selected).SetMode(MODE_POWERRAIL) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2220 |
|
814 | 2221 |
def OnRungTool(self, event): |
2222 |
selected = self.TabsOpened.GetSelection() |
|
2223 |
if selected != -1: |
|
2224 |
self.TabsOpened.GetPage(selected).AddLadderRung() |
|
2225 |
event.Skip() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2226 |
|
814 | 2227 |
def OnCoilTool(self, event): |
2228 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARCOIL) |
|
2229 |
selected = self.TabsOpened.GetSelection() |
|
2230 |
if selected != -1: |
|
2231 |
self.TabsOpened.GetPage(selected).SetMode(MODE_COIL) |
|
2232 |
event.Skip() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2233 |
|
814 | 2234 |
def OnContactTool(self, event): |
2235 |
if self.DrawingMode == FREEDRAWING_MODE: |
|
2236 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARCONTACT) |
|
2237 |
selected = self.TabsOpened.GetSelection() |
|
2238 |
if selected != -1: |
|
2239 |
if self.DrawingMode == FREEDRAWING_MODE: |
|
2240 |
self.TabsOpened.GetPage(selected).SetMode(MODE_CONTACT) |
|
2241 |
else: |
|
2242 |
self.TabsOpened.GetPage(selected).AddLadderContact() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2243 |
|
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2244 |
def OnBranchTool(self, event): |
814 | 2245 |
selected = self.TabsOpened.GetSelection() |
2246 |
if selected != -1: |
|
2247 |
self.TabsOpened.GetPage(selected).AddLadderBranch() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2248 |
|
814 | 2249 |
def OnInitialStepTool(self, event): |
2250 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARINITIALSTEP) |
|
2251 |
selected = self.TabsOpened.GetSelection() |
|
2252 |
if selected != -1: |
|
2253 |
self.TabsOpened.GetPage(selected).SetMode(MODE_INITIALSTEP) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2254 |
|
814 | 2255 |
def OnStepTool(self, event): |
2256 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2257 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARSTEP) |
|
2258 |
selected = self.TabsOpened.GetSelection() |
|
2259 |
if selected != -1: |
|
2260 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2261 |
self.TabsOpened.GetPage(selected).SetMode(MODE_STEP) |
|
2262 |
else: |
|
2263 |
self.TabsOpened.GetPage(selected).AddStep() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2264 |
|
814 | 2265 |
def OnActionBlockTool(self, event): |
2266 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2267 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARACTIONBLOCK) |
|
2268 |
selected = self.TabsOpened.GetSelection() |
|
2269 |
if selected != -1: |
|
2270 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2271 |
self.TabsOpened.GetPage(selected).SetMode(MODE_ACTION) |
|
2272 |
else: |
|
2273 |
self.TabsOpened.GetPage(selected).AddStepAction() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2274 |
|
814 | 2275 |
def OnTransitionTool(self, event): |
2276 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARTRANSITION) |
|
2277 |
selected = self.TabsOpened.GetSelection() |
|
2278 |
if selected != -1: |
|
2279 |
self.TabsOpened.GetPage(selected).SetMode(MODE_TRANSITION) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2280 |
|
814 | 2281 |
def OnDivergenceTool(self, event): |
2282 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2283 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARDIVERGENCE) |
|
2284 |
selected = self.TabsOpened.GetSelection() |
|
2285 |
if selected != -1: |
|
2286 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2287 |
self.TabsOpened.GetPage(selected).SetMode(MODE_DIVERGENCE) |
|
2288 |
else: |
|
2289 |
self.TabsOpened.GetPage(selected).AddDivergence() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2290 |
|
814 | 2291 |
def OnJumpTool(self, event): |
2292 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2293 |
self.ResetToolToggle(ID_PLCOPENEDITOREDITORTOOLBARJUMP) |
|
2294 |
selected = self.TabsOpened.GetSelection() |
|
2295 |
if selected != -1: |
|
2296 |
if self.GetDrawingMode() == FREEDRAWING_MODE: |
|
2297 |
self.TabsOpened.GetPage(selected).SetMode(MODE_JUMP) |
|
2298 |
else: |
|
2299 |
self.TabsOpened.GetPage(selected).AddJump() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2300 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2301 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2302 |
# Add Project Elements Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2303 |
# ------------------------------------------------------------------------------- |
814 | 2304 |
|
1708
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2305 |
def OnAddNewProject(self, event): |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2306 |
# Asks user to create main program after creating new project |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2307 |
AddProgramDialog = self.GenerateAddPouFunction('program', True) |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2308 |
# Checks that user created main program |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2309 |
if AddProgramDialog(event): |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2310 |
self.Controler.SetProjectDefaultConfiguration() |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2311 |
|
814 | 2312 |
def OnAddDataTypeMenu(self, event): |
2313 |
tagname = self.Controler.ProjectAddDataType() |
|
2314 |
if tagname is not None: |
|
2315 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE) |
|
2316 |
self.EditProjectElement(ITEM_DATATYPE, tagname) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2317 |
|
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
2318 |
def GenerateAddPouFunction(self, pou_type, type_readonly=False): |
814 | 2319 |
def OnAddPouMenu(event): |
1708
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2320 |
dialog = PouDialog(self, pou_type, type_readonly) |
814 | 2321 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
2322 |
dialog.SetPouElementNames(self.Controler.GetProjectPouVariableNames()) |
814 | 2323 |
dialog.SetValues({"pouName": self.Controler.GenerateNewName(None, None, "%s%%d" % pou_type)}) |
1708
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2324 |
pou_created = False |
814 | 2325 |
if dialog.ShowModal() == wx.ID_OK: |
2326 |
values = dialog.GetValues() |
|
2327 |
tagname = self.Controler.ProjectAddPou(values["pouName"], values["pouType"], values["language"]) |
|
2328 |
if tagname is not None: |
|
2329 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, LIBRARYTREE) |
|
2330 |
self.EditProjectElement(ITEM_POU, tagname) |
|
1708
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2331 |
dialog.Destroy() |
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2332 |
pou_created = True |
814 | 2333 |
dialog.Destroy() |
1708
24416137cda7
add dialog "add program", that appears after creating new project
Surkov Sergey <surkovsv93@gmail.com>
parents:
1700
diff
changeset
|
2334 |
return pou_created |
814 | 2335 |
return OnAddPouMenu |
2336 |
||
2337 |
def GenerateAddTransitionFunction(self, pou_name): |
|
2338 |
def OnAddTransitionMenu(event): |
|
2339 |
dialog = PouTransitionDialog(self) |
|
2340 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
2341 |
dialog.SetPouElementNames(self.Controler.GetProjectPouVariableNames(pou_name)) |
814 | 2342 |
dialog.SetValues({"transitionName": self.Controler.GenerateNewName(None, None, "transition%d")}) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2343 |
if dialog.ShowModal() == wx.ID_OK: |
814 | 2344 |
values = dialog.GetValues() |
2345 |
tagname = self.Controler.ProjectAddPouTransition(pou_name, values["transitionName"], values["language"]) |
|
2346 |
if tagname is not None: |
|
2347 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE) |
|
2348 |
self.EditProjectElement(ITEM_TRANSITION, tagname) |
|
2349 |
dialog.Destroy() |
|
2350 |
return OnAddTransitionMenu |
|
2351 |
||
2352 |
def GenerateAddActionFunction(self, pou_name): |
|
2353 |
def OnAddActionMenu(event): |
|
2354 |
dialog = PouActionDialog(self) |
|
2355 |
dialog.SetPouNames(self.Controler.GetProjectPouNames()) |
|
1171
a506e4de8f84
Add support for Drag'n dropping located variables to function block creating global located variable in configuration and external variable in function block
Laurent Bessard
parents:
1167
diff
changeset
|
2356 |
dialog.SetPouElementNames(self.Controler.GetProjectPouVariableNames(pou_name)) |
814 | 2357 |
dialog.SetValues({"actionName": self.Controler.GenerateNewName(None, None, "action%d")}) |
2358 |
if dialog.ShowModal() == wx.ID_OK: |
|
2359 |
values = dialog.GetValues() |
|
2360 |
tagname = self.Controler.ProjectAddPouAction(pou_name, values["actionName"], values["language"]) |
|
2361 |
if tagname is not None: |
|
2362 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE) |
|
2363 |
self.EditProjectElement(ITEM_ACTION, tagname) |
|
2364 |
dialog.Destroy() |
|
2365 |
return OnAddActionMenu |
|
2366 |
||
2367 |
def OnAddConfigurationMenu(self, event): |
|
2368 |
tagname = self.Controler.ProjectAddConfiguration() |
|
2369 |
if tagname is not None: |
|
2370 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL) |
|
2371 |
self.EditProjectElement(ITEM_CONFIGURATION, tagname) |
|
2372 |
||
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2373 |
def AddResourceMenu(self, event): |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2374 |
config_names = self.Controler.GetProjectConfigNames() |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2375 |
if len(config_names) > 0: |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2376 |
tagname = self.Controler.ProjectAddConfigurationResource(config_names[0]) |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2377 |
if tagname is not None: |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2378 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL) |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2379 |
self.EditProjectElement(ITEM_RESOURCE, tagname) |
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2380 |
|
814 | 2381 |
def GenerateAddResourceFunction(self, config_name): |
2382 |
def OnAddResourceMenu(event): |
|
2383 |
tagname = self.Controler.ProjectAddConfigurationResource(config_name) |
|
2384 |
if tagname is not None: |
|
2385 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL) |
|
2386 |
self.EditProjectElement(ITEM_RESOURCE, tagname) |
|
2387 |
return OnAddResourceMenu |
|
2388 |
||
2389 |
def GenerateChangePouTypeFunction(self, name, new_type): |
|
2390 |
def OnChangePouTypeMenu(event): |
|
2391 |
selected = self.ProjectTree.GetSelection() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2392 |
if self.ProjectTree.GetPyData(selected)["type"] == ITEM_POU: |
814 | 2393 |
self.Controler.ProjectChangePouType(name, new_type) |
2394 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, PROJECTTREE, LIBRARYTREE) |
|
2395 |
return OnChangePouTypeMenu |
|
2396 |
||
2397 |
def OnCopyPou(self, event): |
|
2398 |
selected = self.ProjectTree.GetSelection() |
|
2399 |
pou_name = self.ProjectTree.GetItemText(selected) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2400 |
|
814 | 2401 |
pou_xml = self.Controler.GetPouXml(pou_name) |
2402 |
if pou_xml is not None: |
|
2403 |
self.SetCopyBuffer(pou_xml) |
|
2404 |
self._Refresh(EDITMENU) |
|
2405 |
||
2406 |
def OnPastePou(self, event): |
|
2407 |
selected = self.ProjectTree.GetSelection() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2408 |
|
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2409 |
if self.ProjectTree.GetPyData(selected)["type"] != ITEM_PROJECT: |
814 | 2410 |
pou_type = self.ProjectTree.GetItemText(selected) |
1737
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
2411 |
pou_type = UNEDITABLE_NAMES_DICT[pou_type] # one of 'Functions', 'Function Blocks' or 'Programs' |
814 | 2412 |
pou_type = {'Functions': 'function', 'Function Blocks': 'functionBlock', 'Programs': 'program'}[pou_type] |
2413 |
else: |
|
2414 |
pou_type = None |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2415 |
|
814 | 2416 |
pou_xml = self.GetCopyBuffer() |
2417 |
||
2418 |
result = self.Controler.PastePou(pou_type, pou_xml) |
|
2419 |
||
2420 |
if not isinstance(result, TupleType): |
|
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2421 |
self.ShowErrorMessage(result) |
814 | 2422 |
else: |
2423 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, PROJECTTREE, LIBRARYTREE) |
|
2424 |
self.EditProjectElement(ITEM_POU, result[0]) |
|
2425 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2426 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2427 |
# Remove Project Elements Functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2428 |
# ------------------------------------------------------------------------------- |
814 | 2429 |
|
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2430 |
def CheckElementIsUsedBeforeDeletion(self, check_function, title, name): |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2431 |
if not check_function(name): |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2432 |
return True |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2433 |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
2434 |
dialog = wx.MessageDialog( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
2435 |
self, |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2436 |
_("\"%s\" is used by one or more POUs. Do you wish to continue?") % name, |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
2437 |
title, wx.YES_NO | wx.ICON_QUESTION) |
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2438 |
answer = dialog.ShowModal() |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2439 |
dialog.Destroy() |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2440 |
return answer == wx.ID_YES |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2441 |
|
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2442 |
def CheckDataTypeIsUsedBeforeDeletion(self, name): |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2443 |
return self.CheckElementIsUsedBeforeDeletion( |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2444 |
self.Controler.DataTypeIsUsed, |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2445 |
_("Remove Datatype"), name) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2446 |
|
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2447 |
def CheckPouIsUsedBeforeDeletion(self, name): |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2448 |
return self.CheckElementIsUsedBeforeDeletion( |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2449 |
self.Controler.PouIsUsed, |
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2450 |
_("Remove Pou"), name) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2451 |
|
814 | 2452 |
def OnRemoveDataTypeMenu(self, event): |
2453 |
selected = self.ProjectTree.GetSelection() |
|
2454 |
if self.ProjectTree.GetPyData(selected)["type"] == ITEM_DATATYPE: |
|
2455 |
name = self.ProjectTree.GetItemText(selected) |
|
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2456 |
if self.CheckDataTypeIsUsedBeforeDeletion(name): |
814 | 2457 |
self.Controler.ProjectRemoveDataType(name) |
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2458 |
tagname = ComputeDataTypeName(name) |
814 | 2459 |
idx = self.IsOpened(tagname) |
2460 |
if idx is not None: |
|
2461 |
self.TabsOpened.DeletePage(idx) |
|
2462 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, PROJECTTREE) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2463 |
|
814 | 2464 |
def OnRenamePouMenu(self, event): |
2465 |
selected = self.ProjectTree.GetSelection() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2466 |
if self.ProjectTree.GetPyData(selected)["type"] == ITEM_POU: |
814 | 2467 |
wx.CallAfter(self.ProjectTree.EditLabel, selected) |
2468 |
||
2469 |
def OnRemovePouMenu(self, event): |
|
2470 |
selected = self.ProjectTree.GetSelection() |
|
2471 |
if self.ProjectTree.GetPyData(selected)["type"] == ITEM_POU: |
|
2472 |
name = self.ProjectTree.GetItemText(selected) |
|
1129
189b49723f9f
Removed restriction on deletion of a POU or DataType already used, replaced by a dialog asking user to confirm
Laurent Bessard
parents:
1112
diff
changeset
|
2473 |
if self.CheckPouIsUsedBeforeDeletion(name): |
814 | 2474 |
self.Controler.ProjectRemovePou(name) |
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2475 |
tagname = ComputePouName(name) |
814 | 2476 |
idx = self.IsOpened(tagname) |
2477 |
if idx is not None: |
|
2478 |
self.TabsOpened.DeletePage(idx) |
|
2479 |
self._Refresh(TITLE, EDITORTOOLBAR, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL, LIBRARYTREE) |
|
2480 |
||
2481 |
def OnRemoveTransitionMenu(self, event): |
|
2482 |
selected = self.ProjectTree.GetSelection() |
|
2483 |
item_infos = self.ProjectTree.GetPyData(selected) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2484 |
if item_infos["type"] == ITEM_TRANSITION: |
814 | 2485 |
transition = self.ProjectTree.GetItemText(selected) |
2486 |
pou_name = item_infos["tagname"].split("::")[1] |
|
2487 |
self.Controler.ProjectRemovePouTransition(pou_name, transition) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2488 |
tagname = ComputePouTransitionName(pou_name, transition) |
814 | 2489 |
idx = self.IsOpened(tagname) |
2490 |
if idx is not None: |
|
2491 |
self.TabsOpened.DeletePage(idx) |
|
2492 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE) |
|
2493 |
||
2494 |
def OnRemoveActionMenu(self, event): |
|
2495 |
selected = self.ProjectTree.GetSelection() |
|
2496 |
item_infos = self.ProjectTree.GetPyData(selected) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2497 |
if item_infos["type"] == ITEM_ACTION: |
814 | 2498 |
action = self.ProjectTree.GetItemText(selected) |
2499 |
pou_name = item_infos["tagname"].split("::")[1] |
|
2500 |
self.Controler.ProjectRemovePouAction(pou_name, action) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2501 |
tagname = ComputePouActionName(pou_name, action) |
814 | 2502 |
idx = self.IsOpened(tagname) |
2503 |
if idx is not None: |
|
2504 |
self.TabsOpened.DeletePage(idx) |
|
2505 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE) |
|
2506 |
||
2507 |
def OnRemoveConfigurationMenu(self, event): |
|
2508 |
selected = self.ProjectTree.GetSelection() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2509 |
if self.ProjectTree.GetPyData(selected)["type"] == ITEM_CONFIGURATION: |
814 | 2510 |
name = self.ProjectTree.GetItemText(selected) |
2511 |
self.Controler.ProjectRemoveConfiguration(name) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2512 |
tagname = ComputeConfigurationName(name) |
814 | 2513 |
idx = self.IsOpened(tagname) |
2514 |
if idx is not None: |
|
2515 |
self.TabsOpened.DeletePage(idx) |
|
2516 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL) |
|
2517 |
||
2518 |
def OnRemoveResourceMenu(self, event): |
|
2519 |
selected = self.ProjectTree.GetSelection() |
|
2520 |
item_infos = self.ProjectTree.GetPyData(selected) |
|
2521 |
if item_infos["type"] == ITEM_RESOURCE: |
|
2522 |
resource = self.ProjectTree.GetItemText(selected) |
|
2523 |
config_name = item_infos["tagname"].split("::")[1] |
|
2524 |
self.Controler.ProjectRemoveConfigurationResource(config_name, resource) |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2525 |
tagname = ComputeConfigurationResourceName(config_name, selected) |
814 | 2526 |
idx = self.IsOpened(tagname) |
2527 |
if idx is not None: |
|
2528 |
self.TabsOpened.DeletePage(idx) |
|
2529 |
self._Refresh(TITLE, FILEMENU, EDITMENU, PROJECTTREE, POUINSTANCEVARIABLESPANEL) |
|
2530 |
||
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2531 |
# ------------------------------------------------------------------------------- |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2532 |
# Highlights showing functions |
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2533 |
# ------------------------------------------------------------------------------- |
814 | 2534 |
|
2535 |
def ShowHighlight(self, infos, start, end, highlight_type): |
|
2536 |
self.SelectProjectTreeItem(infos[0]) |
|
2537 |
if infos[1] == "name": |
|
2538 |
self.Highlights[infos[0]] = highlight_type |
|
2539 |
self.RefreshProjectTree() |
|
2540 |
self.ProjectTree.Unselect() |
|
2541 |
else: |
|
1948
b9a3f771aaab
Moved some definitions away from controller class, and adaped references them through all code.
Edouard Tisserant
parents:
1884
diff
changeset
|
2542 |
self.EditProjectElement(GetElementType(infos[0]), infos[0]) |
814 | 2543 |
selected = self.TabsOpened.GetSelection() |
2544 |
if selected != -1: |
|
2545 |
viewer = self.TabsOpened.GetPage(selected) |
|
2546 |
viewer.AddHighlight(infos[1:], start, end, highlight_type) |
|
2547 |
||
2548 |
def ShowError(self, infos, start, end): |
|
2549 |
self.ShowHighlight(infos, start, end, ERROR_HIGHLIGHT) |
|
2550 |
||
2551 |
def ShowSearchResult(self, infos, start, end): |
|
2552 |
self.ShowHighlight(infos, start, end, SEARCH_RESULT_HIGHLIGHT) |
|
2553 |
||
2554 |
def ClearHighlights(self, highlight_type=None): |
|
2555 |
if highlight_type is None: |
|
2556 |
self.Highlights = {} |
|
2557 |
else: |
|
2558 |
self.Highlights = dict([(name, highlight) for name, highlight in self.Highlights.iteritems() if highlight != highlight_type]) |
|
2559 |
self.RefreshProjectTree() |
|
2560 |
for i in xrange(self.TabsOpened.GetPageCount()): |
|
2561 |
viewer = self.TabsOpened.GetPage(i) |
|
2562 |
viewer.ClearHighlights(highlight_type) |
|
2563 |
||
2564 |
def ClearErrors(self): |
|
2565 |
self.ClearHighlights(ERROR_HIGHLIGHT) |
|
2566 |
||
2567 |
def ClearSearchResults(self): |
|
2568 |
self.ClearHighlights(SEARCH_RESULT_HIGHLIGHT) |
|
838 | 2569 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2570 |
# ------------------------------------------------------------------------------- |
838 | 2571 |
# Viewer Printout |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1781
diff
changeset
|
2572 |
# ------------------------------------------------------------------------------- |
838 | 2573 |
|
1749
d73b64672238
clean-up: fix PEP8 E305 expected 2 blank lines after class or function definition
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1745
diff
changeset
|
2574 |
|
1762
fcc406143e5b
clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
2575 |
def UPPER_DIV(x, y): |
fcc406143e5b
clean-up: fix PEP8 E731 do not assign a lambda expression, use a def
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1749
diff
changeset
|
2576 |
return (x / y) + {True: 0, False: 1}[(x % y) == 0] |
838 | 2577 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
2578 |
|
838 | 2579 |
class GraphicPrintout(wx.Printout): |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1743
diff
changeset
|
2580 |
def __init__(self, viewer, page_size, margins, preview=False): |
838 | 2581 |
wx.Printout.__init__(self) |
2582 |
self.Viewer = viewer |
|
2583 |
self.PageSize = page_size |
|
2584 |
if self.PageSize[0] == 0 or self.PageSize[1] == 0: |
|
2585 |
self.PageSize = (1050, 1485) |
|
2586 |
self.Preview = preview |
|
2587 |
self.Margins = margins |
|
2588 |
self.FontSize = 5 |
|
2589 |
self.TextMargin = 3 |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2590 |
|
838 | 2591 |
maxx, maxy = viewer.GetMaxSize() |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2592 |
self.PageGrid = (UPPER_DIV(maxx, self.PageSize[0]), |
838 | 2593 |
UPPER_DIV(maxy, self.PageSize[1])) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2594 |
|
838 | 2595 |
def GetPageNumber(self): |
2596 |
return self.PageGrid[0] * self.PageGrid[1] |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2597 |
|
838 | 2598 |
def HasPage(self, page): |
2599 |
return page <= self.GetPageNumber() |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2600 |
|
838 | 2601 |
def GetPageInfo(self): |
2602 |
page_number = self.GetPageNumber() |
|
2603 |
return (1, page_number, 1, page_number) |
|
2604 |
||
2605 |
def OnBeginDocument(self, startPage, endPage): |
|
2606 |
dc = self.GetDC() |
|
2607 |
if not self.Preview and isinstance(dc, wx.PostScriptDC): |
|
2608 |
dc.SetResolution(720) |
|
2609 |
super(GraphicPrintout, self).OnBeginDocument(startPage, endPage) |
|
2610 |
||
2611 |
def OnPrintPage(self, page): |
|
2612 |
dc = self.GetDC() |
|
2613 |
dc.SetUserScale(1.0, 1.0) |
|
2614 |
dc.SetDeviceOrigin(0, 0) |
|
2615 |
dc.printing = not self.Preview |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2616 |
|
838 | 2617 |
# Get the size of the DC in pixels |
2618 |
ppiPrinterX, ppiPrinterY = self.GetPPIPrinter() |
|
2619 |
pw, ph = self.GetPageSizePixels() |
|
2620 |
dw, dh = dc.GetSizeTuple() |
|
2621 |
Xscale = (float(dw) * float(ppiPrinterX)) / (float(pw) * 25.4) |
|
2622 |
Yscale = (float(dh) * float(ppiPrinterY)) / (float(ph) * 25.4) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2623 |
|
838 | 2624 |
fontsize = self.FontSize * Yscale |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2625 |
|
838 | 2626 |
margin_left = self.Margins[0].x * Xscale |
2627 |
margin_top = self.Margins[0].y * Yscale |
|
2628 |
area_width = dw - self.Margins[1].x * Xscale - margin_left |
|
2629 |
area_height = dh - self.Margins[1].y * Yscale - margin_top |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2630 |
|
838 | 2631 |
dc.SetPen(MiterPen(wx.BLACK)) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2632 |
dc.SetBrush(wx.TRANSPARENT_BRUSH) |
838 | 2633 |
dc.DrawRectangle(margin_left, margin_top, area_width, area_height) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2634 |
|
838 | 2635 |
dc.SetFont(wx.Font(fontsize, wx.DEFAULT, wx.NORMAL, wx.NORMAL)) |
2636 |
dc.SetTextForeground(wx.BLACK) |
|
2637 |
block_name = " - ".join(self.Viewer.GetTagName().split("::")[1:]) |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1846
diff
changeset
|
2638 |
_text_width, text_height = dc.GetTextExtent(block_name) |
838 | 2639 |
dc.DrawText(block_name, margin_left, margin_top - text_height - self.TextMargin) |
2640 |
dc.DrawText(_("Page: %d") % page, margin_left, margin_top + area_height + self.TextMargin) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2641 |
|
838 | 2642 |
# Calculate the position on the DC for centering the graphic |
2643 |
posX = area_width * ((page - 1) % self.PageGrid[0]) |
|
2644 |
posY = area_height * ((page - 1) / self.PageGrid[0]) |
|
2645 |
||
2646 |
scaleX = float(area_width) / float(self.PageSize[0]) |
|
2647 |
scaleY = float(area_height) / float(self.PageSize[1]) |
|
2648 |
scale = min(scaleX, scaleY) |
|
2649 |
||
2650 |
# Set the scale and origin |
|
2651 |
dc.SetDeviceOrigin(-posX + margin_left, -posY + margin_top) |
|
2652 |
dc.SetClippingRegion(posX, posY, self.PageSize[0] * scale, self.PageSize[1] * scale) |
|
2653 |
dc.SetUserScale(scale, scale) |
|
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2654 |
|
838 | 2655 |
self.Viewer.DoDrawing(dc, True) |
1408
eb2aa27602b7
Fixed launch of PLCopenEditor, broken since 611fded24ce4.
Edouard Tisserant
parents:
1401
diff
changeset
|
2656 |
|
838 | 2657 |
return True |