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