author | Edouard Tisserant |
Thu, 28 May 2020 11:38:09 +0200 | |
branch | svghmi |
changeset 2972 | 1f043fdaa7fb |
parent 2450 | 5024c19ca8f0 |
child 3303 | 0ffb41625592 |
permissions | -rw-r--r-- |
814 | 1 |
#!/usr/bin/env python |
2 |
# -*- coding: utf-8 -*- |
|
3 |
||
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
4 |
# This file is part of Beremiz, a Integrated Development Environment for |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
5 |
# programming IEC 61131-3 automates supporting plcopen standard and CanFestival. |
814 | 6 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
7 |
# Copyright (C) 2012: Edouard TISSERANT and Laurent BESSARD |
814 | 8 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
9 |
# See COPYING file for copyrights details. |
814 | 10 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
11 |
# This program is free software; you can redistribute it and/or |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
12 |
# modify it under the terms of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
13 |
# as published by the Free Software Foundation; either version 2 |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
14 |
# of the License, or (at your option) any later version. |
814 | 15 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
16 |
# This program is distributed in the hope that it will be useful, |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
17 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
18 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
19 |
# GNU General Public License for more details. |
814 | 20 |
# |
1571
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
21 |
# You should have received a copy of the GNU General Public License |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
22 |
# along with this program; if not, write to the Free Software |
486f94a8032c
fix license notices in source files and license files under GPLv2+
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1497
diff
changeset
|
23 |
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. |
814 | 24 |
|
1853
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
25 |
|
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
26 |
from __future__ import absolute_import |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
27 |
from __future__ import division |
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
28 |
from time import time as gettime |
1919
ccea0fa6ea91
Another set of meaningless changes to satisfy PEP8 and PyLint.
Edouard Tisserant
parents:
1878
diff
changeset
|
29 |
from cycler import cycler |
1832
0f1081928d65
fix wrong-import-order. first standard modules are imported, then others
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1823
diff
changeset
|
30 |
|
887
d3c6c4ab8b28
Adding support for displaying graphs of debugged numeric variables in 2D and 3D in DebugVariablePanel
Laurent Bessard
parents:
878
diff
changeset
|
31 |
import numpy |
814 | 32 |
import wx |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
33 |
import matplotlib |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
34 |
import matplotlib.pyplot |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
35 |
from matplotlib.backends.backend_wxagg import FigureCanvasWxAgg as FigureCanvas |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
36 |
from matplotlib.backends.backend_wxagg import _convert_agg_to_wx_bitmap |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
37 |
from matplotlib.backends.backend_agg import FigureCanvasAgg |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
38 |
from mpl_toolkits.mplot3d import Axes3D |
2432
dbc065a2f7a5
python3 support: pylint, W1613 # (xrange-builtin) xrange built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1973
diff
changeset
|
39 |
from six.moves import xrange |
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
40 |
|
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
41 |
from editors.DebugViewer import REFRESH_PERIOD |
1853
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
42 |
from controls.DebugVariablePanel.DebugVariableViewer import * |
47a3f39bead0
fix pylint warning "(relative-import) Relative import 'Y', should be 'X.Y'"
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1850
diff
changeset
|
43 |
from controls.DebugVariablePanel.GraphButton import GraphButton |
1199
fc0e7d80494f
Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents:
1198
diff
changeset
|
44 |
|
1497
7330c85534ea
fix set_color_cycle from matplotlib deprecation warning
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1485
diff
changeset
|
45 |
|
1209 | 46 |
# Graph variable display type |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
47 |
GRAPH_PARALLEL, GRAPH_ORTHOGONAL = range(2) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
48 |
|
1209 | 49 |
# Canvas height |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
50 |
[SIZE_MINI, SIZE_MIDDLE, SIZE_MAXI] = [0, 100, 200] |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
51 |
|
1964
b9318fc8f033
enlarge canvas border for debug variable graphic viewer
Surkov Sergey <surkovsv93@gmail.com>
parents:
1878
diff
changeset
|
52 |
CANVAS_BORDER = (30., 20.) # Border height on at bottom and top of graph |
1737
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
53 |
CANVAS_PADDING = 8.5 # Border inside graph where no label is drawn |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
54 |
VALUE_LABEL_HEIGHT = 17. # Height of variable label in graph |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
55 |
AXES_LABEL_HEIGHT = 12.75 # Height of variable value in graph |
1209 | 56 |
|
57 |
# Colors used cyclically for graph curves |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
58 |
COLOR_CYCLE = ['r', 'b', 'g', 'm', 'y', 'k'] |
1209 | 59 |
# Color for graph cursor |
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
60 |
CURSOR_COLOR = '#800080' |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
61 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
62 |
# ------------------------------------------------------------------------------- |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
63 |
# Debug Variable Graphic Viewer Helpers |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
64 |
# ------------------------------------------------------------------------------- |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
65 |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
66 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
67 |
def merge_ranges(ranges): |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
68 |
""" |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
69 |
Merge variables data range in a list to return a range of minimal min range |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
70 |
value and maximal max range value extended of 10% for keeping a padding |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
71 |
around graph in canvas |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
72 |
@param ranges: [(range_min_value, range_max_value),...] |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
73 |
@return: merged_range_min_value, merged_range_max_value |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
74 |
""" |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
75 |
# Get minimal and maximal range value |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
76 |
min_value = max_value = None |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
77 |
for range_min, range_max in ranges: |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
78 |
# Update minimal range value |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
79 |
if min_value is None: |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
80 |
min_value = range_min |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
81 |
elif range_min is not None: |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
82 |
min_value = min(min_value, range_min) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
83 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
84 |
# Update maximal range value |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
85 |
if max_value is None: |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
86 |
max_value = range_max |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
87 |
elif range_min is not None: |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
88 |
max_value = max(max_value, range_max) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
89 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
90 |
# Calculate range center and width if at least one valid range is defined |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
91 |
if min_value is not None and max_value is not None: |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
92 |
center = (min_value + max_value) / 2. |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
93 |
range_size = max(1.0, max_value - min_value) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
94 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
95 |
# Set default center and with if no valid range is defined |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
96 |
else: |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
97 |
center = 0.5 |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
98 |
range_size = 1.0 |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
99 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
100 |
# Return range expended from 10 % |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
101 |
return center - range_size * 0.55, center + range_size * 0.55 |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
102 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
103 |
# ------------------------------------------------------------------------------- |
1209 | 104 |
# Debug Variable Graphic Viewer Drop Target |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
105 |
# ------------------------------------------------------------------------------- |
1209 | 106 |
|
107 |
||
108 |
class DebugVariableGraphicDropTarget(wx.TextDropTarget): |
|
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
109 |
""" |
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
110 |
Class that implements a custom drop target class for Debug Variable Graphic |
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
111 |
Viewer |
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
112 |
""" |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
113 |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
114 |
def __init__(self, parent, window): |
1209 | 115 |
""" |
116 |
Constructor |
|
117 |
@param parent: Reference to Debug Variable Graphic Viewer |
|
118 |
@param window: Reference to the Debug Variable Panel |
|
119 |
""" |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
120 |
wx.TextDropTarget.__init__(self) |
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
121 |
self.ParentControl = parent |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
122 |
self.ParentWindow = window |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
123 |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
124 |
def __del__(self): |
1209 | 125 |
""" |
126 |
Destructor |
|
127 |
""" |
|
128 |
# Remove reference to Debug Variable Graphic Viewer and Debug Variable |
|
129 |
# Panel |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
130 |
self.ParentControl = None |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
131 |
self.ParentWindow = None |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
132 |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
133 |
def OnDragOver(self, x, y, d): |
1209 | 134 |
""" |
135 |
Function called when mouse is dragged over Drop Target |
|
136 |
@param x: X coordinate of mouse pointer |
|
137 |
@param y: Y coordinate of mouse pointer |
|
138 |
@param d: Suggested default for return value |
|
139 |
""" |
|
140 |
# Signal parent that mouse is dragged over |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
141 |
self.ParentControl.OnMouseDragging(x, y) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
142 |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
143 |
return wx.TextDropTarget.OnDragOver(self, x, y, d) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
144 |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
145 |
def OnDropText(self, x, y, data): |
1209 | 146 |
""" |
1215 | 147 |
Function called when mouse is released in Drop Target |
1209 | 148 |
@param x: X coordinate of mouse pointer |
149 |
@param y: Y coordinate of mouse pointer |
|
150 |
@param data: Text associated to drag'n drop |
|
151 |
""" |
|
1218 | 152 |
# Signal Debug Variable Panel to reset highlight |
153 |
self.ParentWindow.ResetHighlight() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
154 |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
155 |
message = None |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
156 |
|
1209 | 157 |
# Check that data is valid regarding DebugVariablePanel |
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
158 |
try: |
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
159 |
values = eval(data) |
2450
5024c19ca8f0
python3 support: pylint, W1652 # (deprecated-types-field) Accessing a deprecated fields on the types module
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2440
diff
changeset
|
160 |
if not isinstance(values, tuple): |
1207 | 161 |
raise ValueError |
1780
c52d1460cea8
clean-up: fix PEP8 E722 do not use bare except'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1777
diff
changeset
|
162 |
except Exception: |
1734
750eeb7230a1
clean-up: fix some PEP8 E228 missing whitespace around modulo operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1730
diff
changeset
|
163 |
message = _("Invalid value \"%s\" for debug variable") % data |
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
164 |
values = None |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
165 |
|
1209 | 166 |
# Display message if data is invalid |
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
167 |
if message is not None: |
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
168 |
wx.CallAfter(self.ShowMessage, message) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
169 |
|
1209 | 170 |
# Data contain a reference to a variable to debug |
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
171 |
elif values[1] == "debug": |
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
172 |
target_idx = self.ParentControl.GetIndex() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
173 |
|
1209 | 174 |
# If mouse is dropped in graph canvas bounding box and graph is |
175 |
# not 3D canvas, graphs will be merged |
|
176 |
rect = self.ParentControl.GetAxesBoundingBox() |
|
177 |
if not self.ParentControl.Is3DCanvas() and rect.InsideXY(x, y): |
|
178 |
# Default merge type is parallel |
|
179 |
merge_type = GRAPH_PARALLEL |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
180 |
|
1209 | 181 |
# If mouse is dropped in left part of graph canvas, graph |
182 |
# wall be merged orthogonally |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
183 |
merge_rect = wx.Rect(rect.x, rect.y, |
1209 | 184 |
rect.width / 2., rect.height) |
185 |
if merge_rect.InsideXY(x, y): |
|
186 |
merge_type = GRAPH_ORTHOGONAL |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
187 |
|
1209 | 188 |
# Merge graphs |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
189 |
wx.CallAfter(self.ParentWindow.MergeGraphs, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
190 |
values[0], target_idx, |
1209 | 191 |
merge_type, force=True) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
192 |
|
1209 | 193 |
else: |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
194 |
_width, height = self.ParentControl.GetSize() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
195 |
|
1209 | 196 |
# Get Before which Viewer the variable has to be moved or added |
197 |
# according to the position of mouse in Viewer. |
|
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
198 |
if y > height // 2: |
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
199 |
target_idx += 1 |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
200 |
|
1209 | 201 |
# Drag'n Drop is an internal is an internal move inside Debug |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
202 |
# Variable Panel |
1209 | 203 |
if len(values) > 2 and values[2] == "move": |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
204 |
self.ParentWindow.MoveValue(values[0], |
1209 | 205 |
target_idx) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
206 |
|
1209 | 207 |
# Drag'n Drop was initiated by another control of Beremiz |
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
208 |
else: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
209 |
self.ParentWindow.InsertValue(values[0], |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
210 |
target_idx, |
1209 | 211 |
force=True) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
212 |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
213 |
def OnLeave(self): |
1209 | 214 |
""" |
215 |
Function called when mouse is leave Drop Target |
|
216 |
""" |
|
217 |
# Signal Debug Variable Panel to reset highlight |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
218 |
self.ParentWindow.ResetHighlight() |
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
219 |
return wx.TextDropTarget.OnLeave(self) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
220 |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
221 |
def ShowMessage(self, message): |
1209 | 222 |
""" |
223 |
Show error message in Error Dialog |
|
224 |
@param message: Error message to display |
|
225 |
""" |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
226 |
dialog = wx.MessageDialog(self.ParentWindow, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
227 |
message, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
228 |
_("Error"), |
1745
f9d32913bad4
clean-up: fix PEP8 E227 missing whitespace around bitwise or shift operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1744
diff
changeset
|
229 |
wx.OK | wx.ICON_ERROR) |
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
230 |
dialog.ShowModal() |
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
231 |
dialog.Destroy() |
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
232 |
|
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
233 |
|
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
234 |
# ------------------------------------------------------------------------------- |
1209 | 235 |
# Debug Variable Graphic Viewer Class |
1782
5b6ad7a7fd9d
clean-up: fix PEP8 E265 block comment should start with '# '
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1780
diff
changeset
|
236 |
# ------------------------------------------------------------------------------- |
1209 | 237 |
|
238 |
||
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
239 |
class DebugVariableGraphicViewer(DebugVariableViewer, FigureCanvas): |
1736
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
240 |
""" |
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
241 |
Class that implements a Viewer that display variable values as a graphs |
7e61baa047f0
clean-up: fix PEP8 E302 expected 2 blank lines, found 1
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1734
diff
changeset
|
242 |
""" |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
243 |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
244 |
def __init__(self, parent, window, items, graph_type): |
1209 | 245 |
""" |
246 |
Constructor |
|
247 |
@param parent: Parent wx.Window of DebugVariableText |
|
248 |
@param window: Reference to the Debug Variable Panel |
|
249 |
@param items: List of DebugVariableItem displayed by Viewer |
|
250 |
@param graph_type: Graph display type (Parallel or orthogonal) |
|
251 |
""" |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
252 |
DebugVariableViewer.__init__(self, window, items) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
253 |
|
1209 | 254 |
self.GraphType = graph_type # Graph type display |
255 |
self.CursorTick = None # Tick of the graph cursor |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
256 |
|
1209 | 257 |
# Mouse position when start dragging |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
258 |
self.MouseStartPos = None |
1209 | 259 |
# Tick when moving tick start |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
260 |
self.StartCursorTick = None |
1209 | 261 |
# Canvas size when starting to resize canvas |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
262 |
self.CanvasStartSize = None |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
263 |
|
1209 | 264 |
# List of current displayed contextual buttons |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
265 |
self.ContextualButtons = [] |
1209 | 266 |
# Reference to item for which contextual buttons was displayed |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
267 |
self.ContextualButtonsItem = None |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
268 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
269 |
# Flag indicating that zoom fit current displayed data range or whole |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
270 |
# data range if False |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
271 |
self.ZoomFit = False |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
272 |
|
1209 | 273 |
# Create figure for drawing graphs |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
274 |
self.Figure = matplotlib.figure.Figure(facecolor='w') |
1209 | 275 |
# Defined border around figure in canvas |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
276 |
self.Figure.subplotpars.update(top=0.95, left=0.1, |
1209 | 277 |
bottom=0.1, right=0.95) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
278 |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
279 |
FigureCanvas.__init__(self, parent, -1, self.Figure) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
280 |
self.SetWindowStyle(wx.WANTS_CHARS) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
281 |
self.SetBackgroundColour(wx.WHITE) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
282 |
|
1209 | 283 |
# Bind wx events |
1214
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
284 |
self.Bind(wx.EVT_LEFT_DCLICK, self.OnLeftDClick) |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
285 |
self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
286 |
self.Bind(wx.EVT_ENTER_WINDOW, self.OnEnter) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
287 |
self.Bind(wx.EVT_LEAVE_WINDOW, self.OnLeave) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
288 |
self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
289 |
self.Bind(wx.EVT_SIZE, self.OnResize) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
290 |
|
1209 | 291 |
# Set canvas min size |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
292 |
canvas_size = self.GetCanvasMinSize() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
293 |
self.SetMinSize(canvas_size) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
294 |
|
1209 | 295 |
# Define Viewer drop target |
296 |
self.SetDropTarget(DebugVariableGraphicDropTarget(self, window)) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
297 |
|
1209 | 298 |
# Connect matplotlib events |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
299 |
self.mpl_connect('button_press_event', self.OnCanvasButtonPressed) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
300 |
self.mpl_connect('motion_notify_event', self.OnCanvasMotion) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
301 |
self.mpl_connect('button_release_event', self.OnCanvasButtonReleased) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
302 |
self.mpl_connect('scroll_event', self.OnCanvasScroll) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
303 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
304 |
# Add buttons for zooming on current displayed data range |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
305 |
self.Buttons.append( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
306 |
GraphButton(0, 0, "fit_graph", self.OnZoomFitButton)) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
307 |
|
1209 | 308 |
# Add buttons for changing canvas size with predefined height |
309 |
for size, bitmap in zip( |
|
310 |
[SIZE_MINI, SIZE_MIDDLE, SIZE_MAXI], |
|
311 |
["minimize_graph", "middle_graph", "maximize_graph"]): |
|
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
312 |
self.Buttons.append(GraphButton(0, 0, bitmap, |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
313 |
self.GetOnChangeSizeButton(size))) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
314 |
|
1209 | 315 |
# Add buttons for exporting graph values to clipboard and close graph |
316 |
for bitmap, callback in [ |
|
317 |
("export_graph_mini", self.OnExportGraphButton), |
|
318 |
("delete_graph", self.OnCloseButton)]: |
|
1199
fc0e7d80494f
Move GraphButton from DebugVariableGraphicPanel to separate file
Laurent Bessard
parents:
1198
diff
changeset
|
319 |
self.Buttons.append(GraphButton(0, 0, bitmap, callback)) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
320 |
|
1209 | 321 |
# Update graphs elements |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
322 |
self.ResetGraphics() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
323 |
self.RefreshLabelsPosition(canvas_size.height) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
324 |
|
1209 | 325 |
def AddItem(self, item): |
326 |
""" |
|
327 |
Add an item to the list of items displayed by Viewer |
|
328 |
@param item: Item to add to the list |
|
329 |
""" |
|
330 |
DebugVariableViewer.AddItem(self, item) |
|
331 |
self.ResetGraphics() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
332 |
|
1209 | 333 |
def RemoveItem(self, item): |
334 |
""" |
|
335 |
Remove an item from the list of items displayed by Viewer |
|
336 |
@param item: Item to remove from the list |
|
337 |
""" |
|
338 |
DebugVariableViewer.RemoveItem(self, item) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
339 |
|
1209 | 340 |
# If list of items is not empty |
341 |
if not self.ItemsIsEmpty(): |
|
342 |
# Return to parallel graph if there is only one item |
|
343 |
# especially if it's actually orthogonal |
|
344 |
if len(self.Items) == 1: |
|
345 |
self.GraphType = GRAPH_PARALLEL |
|
346 |
self.ResetGraphics() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
347 |
|
1212 | 348 |
def SetCursorTick(self, cursor_tick): |
349 |
""" |
|
350 |
Set cursor tick |
|
351 |
@param cursor_tick: Cursor tick |
|
352 |
""" |
|
353 |
self.CursorTick = cursor_tick |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
354 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
355 |
def SetZoomFit(self, zoom_fit): |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
356 |
""" |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
357 |
Set flag indicating that zoom fit current displayed data range |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
358 |
@param zoom_fit: Flag for zoom fit (False: zoom fit whole data range) |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
359 |
""" |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
360 |
# Flag is different from the actual one |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
361 |
if zoom_fit != self.ZoomFit: |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
362 |
# Save new flag value |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
363 |
self.ZoomFit = zoom_fit |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
364 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
365 |
# Update button for zoom fit bitmap |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
366 |
self.Buttons[0].SetBitmap("full_graph" if zoom_fit else "fit_graph") |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
367 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
368 |
# Refresh canvas |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
369 |
self.RefreshViewer() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
370 |
|
1209 | 371 |
def SubscribeAllDataConsumers(self): |
372 |
""" |
|
373 |
Function that unsubscribe and remove every item that store values of |
|
374 |
a variable that doesn't exist in PLC anymore |
|
375 |
""" |
|
376 |
DebugVariableViewer.SubscribeAllDataConsumers(self) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
377 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
378 |
# Graph still have data to display |
1209 | 379 |
if not self.ItemsIsEmpty(): |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
380 |
# Reset flag indicating that zoom fit current displayed data range |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
381 |
self.SetZoomFit(False) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
382 |
|
1209 | 383 |
self.ResetGraphics() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
384 |
|
1209 | 385 |
def Is3DCanvas(self): |
386 |
""" |
|
387 |
Return if Viewer is a 3D canvas |
|
388 |
@return: True if Viewer is a 3D canvas |
|
389 |
""" |
|
390 |
return self.GraphType == GRAPH_ORTHOGONAL and len(self.Items) == 3 |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
391 |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
392 |
def GetButtons(self): |
1209 | 393 |
""" |
394 |
Return list of buttons defined in Viewer |
|
395 |
@return: List of buttons |
|
396 |
""" |
|
397 |
# Add contextual buttons to default buttons |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
398 |
return self.Buttons + self.ContextualButtons |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
399 |
|
1209 | 400 |
def PopupContextualButtons(self, item, rect, direction=wx.RIGHT): |
401 |
""" |
|
402 |
Show contextual menu for item aside a label of this item defined |
|
403 |
by the bounding box of label in figure |
|
404 |
@param item: Item for which contextual is shown |
|
405 |
@param rect: Bounding box of label aside which drawing menu |
|
406 |
@param direction: Direction in which buttons must be drawn |
|
407 |
""" |
|
408 |
# Return immediately if contextual menu for item is already shown |
|
409 |
if self.ContextualButtonsItem == item: |
|
410 |
return |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
411 |
|
1209 | 412 |
# Close already shown contextual menu |
413 |
self.DismissContextualButtons() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
414 |
|
1209 | 415 |
# Save item for which contextual menu is shown |
416 |
self.ContextualButtonsItem = item |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
417 |
|
1209 | 418 |
# If item variable is forced, add button for release variable to |
419 |
# contextual menu |
|
420 |
if self.ContextualButtonsItem.IsForced(): |
|
421 |
self.ContextualButtons.append( |
|
422 |
GraphButton(0, 0, "release", self.OnReleaseItemButton)) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
423 |
|
1209 | 424 |
# Add other buttons to contextual menu |
425 |
for bitmap, callback in [ |
|
426 |
("force", self.OnForceItemButton), |
|
427 |
("export_graph_mini", self.OnExportItemGraphButton), |
|
428 |
("delete_graph", self.OnRemoveItemButton)]: |
|
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
429 |
self.ContextualButtons.append(GraphButton(0, 0, bitmap, callback)) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
430 |
|
1209 | 431 |
# If buttons are shown at left side or upper side of rect, positions |
432 |
# will be set in reverse order |
|
433 |
buttons = self.ContextualButtons[:] |
|
434 |
if direction in [wx.TOP, wx.LEFT]: |
|
1757
0de89da92ee0
clean-up: fix PEP8 E111 indentation is not a multiple of four
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1750
diff
changeset
|
435 |
buttons.reverse() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
436 |
|
1209 | 437 |
# Set contextual menu buttons position aside rect depending on |
438 |
# direction given |
|
439 |
offset = 0 |
|
440 |
for button in buttons: |
|
441 |
w, h = button.GetSize() |
|
442 |
if direction in [wx.LEFT, wx.RIGHT]: |
|
443 |
x = rect.x + (- w - offset |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
444 |
if direction == wx.LEFT |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
445 |
else rect.width + offset) |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
446 |
y = rect.y + (rect.height - h) // 2 |
1209 | 447 |
offset += w |
448 |
else: |
|
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
449 |
x = rect.x + (rect.width - w) // 2 |
1209 | 450 |
y = rect.y + (- h - offset |
451 |
if direction == wx.TOP |
|
452 |
else rect.height + offset) |
|
453 |
offset += h |
|
454 |
button.SetPosition(x, y) |
|
455 |
button.Show() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
456 |
|
1209 | 457 |
# Refresh canvas |
458 |
self.ParentWindow.ForceRefresh() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
459 |
|
1209 | 460 |
def DismissContextualButtons(self): |
461 |
""" |
|
462 |
Close current shown contextual menu |
|
463 |
""" |
|
464 |
# Return immediately if no contextual menu is shown |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
465 |
if self.ContextualButtonsItem is None: |
1209 | 466 |
return |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
467 |
|
1209 | 468 |
# Reset variables corresponding to contextual menu |
469 |
self.ContextualButtonsItem = None |
|
470 |
self.ContextualButtons = [] |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
471 |
|
1209 | 472 |
# Refresh canvas |
473 |
self.ParentWindow.ForceRefresh() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
474 |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
475 |
def IsOverContextualButton(self, x, y): |
1209 | 476 |
""" |
477 |
Return if point is over one contextual button of Viewer |
|
478 |
@param x: X coordinate of point |
|
479 |
@param y: Y coordinate of point |
|
480 |
@return: contextual button where point is over |
|
481 |
""" |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
482 |
for button in self.ContextualButtons: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
483 |
if button.HitTest(x, y): |
1209 | 484 |
return button |
485 |
return None |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
486 |
|
1209 | 487 |
def ExportGraph(self, item=None): |
488 |
""" |
|
489 |
Export item(s) data to clipboard in CSV format |
|
490 |
@param item: Item from which data to export, all items if None |
|
491 |
(default None) |
|
492 |
""" |
|
493 |
self.ParentWindow.CopyDataToClipboard( |
|
494 |
[(item, [entry for entry in item.GetData()]) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
495 |
for item in (self.Items |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
496 |
if item is None |
1209 | 497 |
else [item])]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
498 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
499 |
def OnZoomFitButton(self): |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
500 |
""" |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
501 |
Function called when Viewer Zoom Fit button is pressed |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
502 |
""" |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
503 |
# Toggle zoom fit flag value |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
504 |
self.SetZoomFit(not self.ZoomFit) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
505 |
|
1209 | 506 |
def GetOnChangeSizeButton(self, height): |
507 |
""" |
|
508 |
Function that generate callback function for change Viewer height to |
|
509 |
pre-defined height button |
|
510 |
@param height: Height that change Viewer to |
|
511 |
@return: callback function |
|
512 |
""" |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
513 |
def OnChangeSizeButton(): |
1264 | 514 |
self.SetCanvasHeight(height) |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
515 |
return OnChangeSizeButton |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
516 |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
517 |
def OnExportGraphButton(self): |
1209 | 518 |
""" |
519 |
Function called when Viewer Export button is pressed |
|
520 |
""" |
|
521 |
# Export data of every item in Viewer |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
522 |
self.ExportGraph() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
523 |
|
1209 | 524 |
def OnForceItemButton(self): |
525 |
""" |
|
526 |
Function called when contextual menu Force button is pressed |
|
527 |
""" |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
528 |
# Open dialog for forcing item variable value |
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
529 |
self.ForceValue(self.ContextualButtonsItem) |
1209 | 530 |
# Close contextual menu |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
531 |
self.DismissContextualButtons() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
532 |
|
1209 | 533 |
def OnReleaseItemButton(self): |
534 |
""" |
|
535 |
Function called when contextual menu Release button is pressed |
|
536 |
""" |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
537 |
# Release item variable value |
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
538 |
self.ReleaseValue(self.ContextualButtonsItem) |
1209 | 539 |
# Close contextual menu |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
540 |
self.DismissContextualButtons() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
541 |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
542 |
def OnExportItemGraphButton(self): |
1209 | 543 |
""" |
544 |
Function called when contextual menu Export button is pressed |
|
545 |
""" |
|
546 |
# Export data of item variable |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
547 |
self.ExportGraph(self.ContextualButtonsItem) |
1209 | 548 |
# Close contextual menu |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
549 |
self.DismissContextualButtons() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
550 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
551 |
def OnRemoveItemButton(self): |
1209 | 552 |
""" |
553 |
Function called when contextual menu Remove button is pressed |
|
554 |
""" |
|
555 |
# Remove item from Viewer |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
556 |
wx.CallAfter(self.ParentWindow.DeleteValue, self, |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
557 |
self.ContextualButtonsItem) |
1209 | 558 |
# Close contextual menu |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
559 |
self.DismissContextualButtons() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
560 |
|
1209 | 561 |
def HandleCursorMove(self, event): |
1212 | 562 |
""" |
563 |
Update Cursor position according to mouse position and graph type |
|
564 |
@param event: Mouse event |
|
565 |
""" |
|
1209 | 566 |
start_tick, end_tick = self.ParentWindow.GetRange() |
567 |
cursor_tick = None |
|
568 |
items = self.ItemsDict.values() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
569 |
|
1212 | 570 |
# Graph is orthogonal |
1209 | 571 |
if self.GraphType == GRAPH_ORTHOGONAL: |
1212 | 572 |
# Extract items data displayed in canvas figure |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
573 |
start_tick = max(start_tick, self.GetItemsMinCommonTick()) |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
574 |
end_tick = max(end_tick, start_tick) |
1209 | 575 |
x_data = items[0].GetData(start_tick, end_tick) |
576 |
y_data = items[1].GetData(start_tick, end_tick) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
577 |
|
1212 | 578 |
# Search for the nearest point from mouse position |
1209 | 579 |
if len(x_data) > 0 and len(y_data) > 0: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
580 |
length = min(len(x_data), len(y_data)) |
1764
d5df428640ff
clean-up: fix PEP8 E502 the backslash is redundant between brackets
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1757
diff
changeset
|
581 |
d = numpy.sqrt((x_data[:length, 1]-event.xdata) ** 2 + |
1740
b789b695b5c6
clean-up: fix PEP8 E231 missing whitespace after ':' or ','
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1737
diff
changeset
|
582 |
(y_data[:length, 1]-event.ydata) ** 2) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
583 |
|
1212 | 584 |
# Set cursor tick to the tick of this point |
1209 | 585 |
cursor_tick = x_data[numpy.argmin(d), 0] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
586 |
|
1212 | 587 |
# Graph is parallel |
1209 | 588 |
else: |
1212 | 589 |
# Extract items tick |
1209 | 590 |
data = items[0].GetData(start_tick, end_tick) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
591 |
|
1212 | 592 |
# Search for point that tick is the nearest from mouse X position |
593 |
# and set cursor tick to the tick of this point |
|
1209 | 594 |
if len(data) > 0: |
1212 | 595 |
cursor_tick = data[numpy.argmin( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
596 |
numpy.abs(data[:, 0] - event.xdata)), 0] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
597 |
|
1212 | 598 |
# Update cursor tick |
1209 | 599 |
if cursor_tick is not None: |
600 |
self.ParentWindow.SetCursorTick(cursor_tick) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
601 |
|
1209 | 602 |
def OnCanvasButtonPressed(self, event): |
603 |
""" |
|
604 |
Function called when a button of mouse is pressed |
|
605 |
@param event: Mouse event |
|
606 |
""" |
|
1212 | 607 |
# Get mouse position, graph Y coordinate is inverted in matplotlib |
608 |
# comparing to wx |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
609 |
_width, height = self.GetSize() |
1209 | 610 |
x, y = event.x, height - event.y |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
611 |
|
1209 | 612 |
# Return immediately if mouse is over a button |
613 |
if self.IsOverButton(x, y): |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
614 |
return |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
615 |
|
1209 | 616 |
# Mouse was clicked inside graph figure |
617 |
if event.inaxes == self.Axes: |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
618 |
|
1209 | 619 |
# Find if it was on an item label |
620 |
item_idx = None |
|
621 |
# Check every label paired with corresponding item |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
622 |
for i, t in ([pair for pair in enumerate(self.AxesLabels)] + |
1209 | 623 |
[pair for pair in enumerate(self.Labels)]): |
624 |
# Get label bounding box |
|
625 |
(x0, y0), (x1, y1) = t.get_window_extent().get_points() |
|
626 |
rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0) |
|
627 |
# Check if mouse was over label |
|
628 |
if rect.InsideXY(x, y): |
|
629 |
item_idx = i |
|
630 |
break |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
631 |
|
1209 | 632 |
# If an item label have been clicked |
633 |
if item_idx is not None: |
|
634 |
# Hide buttons and contextual buttons |
|
635 |
self.ShowButtons(False) |
|
636 |
self.DismissContextualButtons() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
637 |
|
1209 | 638 |
# Start a drag'n drop from mouse position in wx coordinate of |
639 |
# parent |
|
640 |
xw, yw = self.GetPosition() |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
641 |
self.ParentWindow.StartDragNDrop( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
642 |
self, self.ItemsDict.values()[item_idx], |
1737
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
643 |
x + xw, y + yw, # Current mouse position |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
644 |
x + xw, y + yw) # Mouse position when button was clicked |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
645 |
|
1209 | 646 |
# Don't handle mouse button if canvas is 3D and let matplotlib do |
647 |
# the default behavior (rotate 3D axes) |
|
648 |
elif not self.Is3DCanvas(): |
|
649 |
# Save mouse position when clicked |
|
650 |
self.MouseStartPos = wx.Point(x, y) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
651 |
|
1209 | 652 |
# Mouse button was left button, start moving cursor |
653 |
if event.button == 1: |
|
654 |
# Save current tick in case a drag'n drop is initiate to |
|
655 |
# restore it |
|
656 |
self.StartCursorTick = self.CursorTick |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
657 |
|
1209 | 658 |
self.HandleCursorMove(event) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
659 |
|
1209 | 660 |
# Mouse button is middle button and graph is parallel, start |
661 |
# moving graph along X coordinate (tick) |
|
662 |
elif event.button == 2 and self.GraphType == GRAPH_PARALLEL: |
|
663 |
self.StartCursorTick = self.ParentWindow.GetRange()[0] |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
664 |
|
1209 | 665 |
# Mouse was clicked outside graph figure and over resize highlight with |
666 |
# left button, start resizing Viewer |
|
667 |
elif event.button == 1 and event.y <= 5: |
|
668 |
self.MouseStartPos = wx.Point(x, y) |
|
669 |
self.CanvasStartSize = height |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
670 |
|
1209 | 671 |
def OnCanvasButtonReleased(self, event): |
672 |
""" |
|
673 |
Function called when a button of mouse is released |
|
674 |
@param event: Mouse event |
|
675 |
""" |
|
676 |
# If a drag'n drop is in progress, stop it |
|
677 |
if self.ParentWindow.IsDragging(): |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
678 |
_width, height = self.GetSize() |
1209 | 679 |
xw, yw = self.GetPosition() |
680 |
item = self.ParentWindow.DraggingAxesPanel.ItemsDict.values()[0] |
|
681 |
# Give mouse position in wx coordinate of parent |
|
682 |
self.ParentWindow.StopDragNDrop(item.GetVariable(), |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
683 |
xw + event.x, yw + height - event.y) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
684 |
|
1209 | 685 |
else: |
686 |
# Reset any move in progress |
|
687 |
self.MouseStartPos = None |
|
688 |
self.CanvasStartSize = None |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
689 |
|
1209 | 690 |
# Handle button under mouse if it exist |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
691 |
_width, height = self.GetSize() |
1209 | 692 |
self.HandleButton(event.x, height - event.y) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
693 |
|
1209 | 694 |
def OnCanvasMotion(self, event): |
695 |
""" |
|
696 |
Function called when a button of mouse is moved over Viewer |
|
697 |
@param event: Mouse event |
|
698 |
""" |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
699 |
_width, height = self.GetSize() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
700 |
|
1209 | 701 |
# If a drag'n drop is in progress, move canvas dragged |
702 |
if self.ParentWindow.IsDragging(): |
|
703 |
xw, yw = self.GetPosition() |
|
704 |
# Give mouse position in wx coordinate of parent |
|
705 |
self.ParentWindow.MoveDragNDrop( |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
706 |
xw + event.x, |
1209 | 707 |
yw + height - event.y) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
708 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
709 |
# If a Viewer resize is in progress, change Viewer size |
1209 | 710 |
elif event.button == 1 and self.CanvasStartSize is not None: |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
711 |
_width, height = self.GetSize() |
1264 | 712 |
self.SetCanvasHeight( |
1209 | 713 |
self.CanvasStartSize + height - event.y - self.MouseStartPos.y) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
714 |
|
1209 | 715 |
# If no button is pressed, show or hide contextual buttons or resize |
716 |
# highlight |
|
717 |
elif event.button is None: |
|
718 |
# Compute direction for items label according graph type |
|
1737
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
719 |
if self.GraphType == GRAPH_PARALLEL: # Graph is parallel |
1209 | 720 |
directions = [wx.RIGHT] * len(self.AxesLabels) + \ |
721 |
[wx.LEFT] * len(self.Labels) |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
722 |
elif len(self.AxesLabels) > 0: # Graph is orthogonal in 2D |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
723 |
directions = [wx.RIGHT, wx.TOP, # Directions for AxesLabels |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
724 |
wx.LEFT, wx.BOTTOM] # Directions for Labels |
1737
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
725 |
else: # Graph is orthogonal in 3D |
1209 | 726 |
directions = [wx.LEFT] * len(self.Labels) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
727 |
|
1209 | 728 |
# Find if mouse is over an item label |
729 |
item_idx = None |
|
730 |
menu_direction = None |
|
731 |
for (i, t), dir in zip( |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
732 |
[pair for pair in enumerate(self.AxesLabels)] + |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
733 |
[pair for pair in enumerate(self.Labels)], |
1209 | 734 |
directions): |
735 |
# Check every label paired with corresponding item |
|
736 |
(x0, y0), (x1, y1) = t.get_window_extent().get_points() |
|
737 |
rect = wx.Rect(x0, height - y1, x1 - x0, y1 - y0) |
|
738 |
# Check if mouse was over label |
|
739 |
if rect.InsideXY(event.x, height - event.y): |
|
740 |
item_idx = i |
|
741 |
menu_direction = dir |
|
742 |
break |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
743 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
744 |
# If mouse is over an item label, |
1209 | 745 |
if item_idx is not None: |
746 |
self.PopupContextualButtons( |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
747 |
self.ItemsDict.values()[item_idx], |
1209 | 748 |
rect, menu_direction) |
749 |
return |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
750 |
|
1209 | 751 |
# If mouse isn't over a contextual menu, hide the current shown one |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
752 |
# if it exists |
1209 | 753 |
if self.IsOverContextualButton(event.x, height - event.y) is None: |
754 |
self.DismissContextualButtons() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
755 |
|
1209 | 756 |
# Update resize highlight |
757 |
if event.y <= 5: |
|
758 |
if self.SetHighlight(HIGHLIGHT_RESIZE): |
|
759 |
self.SetCursor(wx.StockCursor(wx.CURSOR_SIZENS)) |
|
760 |
self.ParentWindow.ForceRefresh() |
|
761 |
else: |
|
762 |
if self.SetHighlight(HIGHLIGHT_NONE): |
|
763 |
self.SetCursor(wx.NullCursor) |
|
764 |
self.ParentWindow.ForceRefresh() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
765 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
766 |
# Handle buttons if canvas is not 3D |
1209 | 767 |
elif not self.Is3DCanvas(): |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
768 |
|
1209 | 769 |
# If left button is pressed |
770 |
if event.button == 1: |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
771 |
|
1209 | 772 |
# Mouse is inside graph figure |
773 |
if event.inaxes == self.Axes: |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
774 |
|
1209 | 775 |
# If a cursor move is in progress, update cursor position |
776 |
if self.MouseStartPos is not None: |
|
777 |
self.HandleCursorMove(event) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
778 |
|
1209 | 779 |
# Mouse is outside graph figure, cursor move is in progress and |
780 |
# there is only one item in Viewer, start a drag'n drop |
|
781 |
elif self.MouseStartPos is not None and len(self.Items) == 1: |
|
782 |
xw, yw = self.GetPosition() |
|
783 |
self.ParentWindow.SetCursorTick(self.StartCursorTick) |
|
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
784 |
self.ParentWindow.StartDragNDrop( |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
785 |
self, self.ItemsDict.values()[0], |
1209 | 786 |
# Current mouse position |
787 |
event.x + xw, height - event.y + yw, |
|
788 |
# Mouse position when button was clicked |
|
789 |
self.MouseStartPos.x + xw, |
|
790 |
self.MouseStartPos.y + yw) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
791 |
|
1209 | 792 |
# If middle button is pressed and moving graph along X coordinate |
793 |
# is in progress |
|
1767
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
794 |
elif (event.button == 2 and |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
795 |
self.GraphType == GRAPH_PARALLEL and |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
796 |
self.MouseStartPos is not None): |
1209 | 797 |
start_tick, end_tick = self.ParentWindow.GetRange() |
798 |
rect = self.GetAxesBoundingBox() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
799 |
|
1209 | 800 |
# Move graph along X coordinate |
801 |
self.ParentWindow.SetCanvasPosition( |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
802 |
self.StartCursorTick + |
1209 | 803 |
(self.MouseStartPos.x - event.x) * |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
804 |
(end_tick - start_tick) // rect.width) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
805 |
|
1209 | 806 |
def OnCanvasScroll(self, event): |
807 |
""" |
|
808 |
Function called when a wheel mouse is use in Viewer |
|
809 |
@param event: Mouse event |
|
810 |
""" |
|
811 |
# Change X range of graphs if mouse is in canvas figure and ctrl is |
|
812 |
# pressed |
|
813 |
if event.inaxes is not None and event.guiEvent.ControlDown(): |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
814 |
|
1209 | 815 |
# Calculate position of fixed tick point according to graph type |
816 |
# and mouse position |
|
817 |
if self.GraphType == GRAPH_ORTHOGONAL: |
|
818 |
start_tick, end_tick = self.ParentWindow.GetRange() |
|
819 |
tick = (start_tick + end_tick) / 2. |
|
820 |
else: |
|
821 |
tick = event.xdata |
|
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
822 |
self.ParentWindow.ChangeRange(int(-event.step) // 3, tick) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
823 |
|
1209 | 824 |
# Vetoing event to prevent parent panel to be scrolled |
825 |
self.ParentWindow.VetoScrollEvent = True |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
826 |
|
1214
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
827 |
def OnLeftDClick(self, event): |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
828 |
""" |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
829 |
Function called when a left mouse button is double clicked |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
830 |
@param event: Mouse event |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
831 |
""" |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
832 |
# Check that double click was done inside figure |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
833 |
pos = event.GetPosition() |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
834 |
rect = self.GetAxesBoundingBox() |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
835 |
if rect.InsideXY(pos.x, pos.y): |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
836 |
# Reset Cursor tick to value before starting clicking |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
837 |
self.ParentWindow.SetCursorTick(self.StartCursorTick) |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
838 |
# Toggle to text Viewer(s) |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
839 |
self.ParentWindow.ToggleViewerType(self) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
840 |
|
1214
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
841 |
else: |
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
842 |
event.Skip() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
843 |
|
1209 | 844 |
# Cursor tick move for each arrow key |
845 |
KEY_CURSOR_INCREMENT = { |
|
846 |
wx.WXK_LEFT: -1, |
|
847 |
wx.WXK_RIGHT: 1, |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
848 |
wx.WXK_UP: 10, |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
849 |
wx.WXK_DOWN: -10} |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
850 |
|
1209 | 851 |
def OnKeyDown(self, event): |
852 |
""" |
|
853 |
Function called when key is pressed |
|
854 |
@param event: wx.KeyEvent |
|
855 |
""" |
|
856 |
# If cursor is shown and arrow key is pressed, move cursor tick |
|
857 |
if self.CursorTick is not None: |
|
858 |
move = self.KEY_CURSOR_INCREMENT.get(event.GetKeyCode(), None) |
|
859 |
if move is not None: |
|
860 |
self.ParentWindow.MoveCursorTick(move) |
|
861 |
event.Skip() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
862 |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
863 |
def OnLeave(self, event): |
1209 | 864 |
""" |
865 |
Function called when mouse leave Viewer |
|
866 |
@param event: wx.MouseEvent |
|
867 |
""" |
|
868 |
# If Viewer is not resizing, reset resize highlight |
|
869 |
if self.CanvasStartSize is None: |
|
870 |
self.SetHighlight(HIGHLIGHT_NONE) |
|
871 |
self.SetCursor(wx.NullCursor) |
|
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
872 |
DebugVariableViewer.OnLeave(self, event) |
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
873 |
else: |
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
874 |
event.Skip() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
875 |
|
1212 | 876 |
def GetCanvasMinSize(self): |
877 |
""" |
|
878 |
Return the minimum size of Viewer so that all items label can be |
|
879 |
displayed |
|
880 |
@return: wx.Size containing Viewer minimum size |
|
881 |
""" |
|
882 |
# The minimum height take in account the height of all items, padding |
|
883 |
# inside figure and border around figure |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
884 |
return wx.Size(200, |
1768
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
885 |
CANVAS_BORDER[0] + CANVAS_BORDER[1] + |
691083b5682a
clean-up: fix PEP8 E128 continuation line under-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1767
diff
changeset
|
886 |
2 * CANVAS_PADDING + VALUE_LABEL_HEIGHT * len(self.Items)) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
887 |
|
1264 | 888 |
def SetCanvasHeight(self, height): |
1212 | 889 |
""" |
890 |
Set Viewer size checking that it respects Viewer minimum size |
|
891 |
@param height: Viewer height |
|
892 |
""" |
|
1264 | 893 |
min_width, min_height = self.GetCanvasMinSize() |
894 |
height = max(height, min_height) |
|
895 |
self.SetMinSize(wx.Size(min_width, height)) |
|
1212 | 896 |
self.RefreshLabelsPosition(height) |
897 |
self.ParentWindow.RefreshGraphicsSizer() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
898 |
|
1212 | 899 |
def GetAxesBoundingBox(self, parent_coordinate=False): |
900 |
""" |
|
901 |
Return figure bounding box in wx coordinate |
|
902 |
@param parent_coordinate: True if use parent coordinate (default False) |
|
903 |
""" |
|
904 |
# Calculate figure bounding box. Y coordinate is inverted in matplotlib |
|
905 |
# figure comparing to wx panel |
|
906 |
width, height = self.GetSize() |
|
907 |
ax, ay, aw, ah = self.figure.gca().get_position().bounds |
|
908 |
bbox = wx.Rect(ax * width, height - (ay + ah) * height - 1, |
|
909 |
aw * width + 2, ah * height + 1) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
910 |
|
1212 | 911 |
# If parent_coordinate, add Viewer position in parent |
912 |
if parent_coordinate: |
|
913 |
xw, yw = self.GetPosition() |
|
914 |
bbox.x += xw |
|
915 |
bbox.y += yw |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
916 |
|
1212 | 917 |
return bbox |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
918 |
|
1212 | 919 |
def RefreshHighlight(self, x, y): |
920 |
""" |
|
921 |
Refresh Viewer highlight according to mouse position |
|
922 |
@param x: X coordinate of mouse pointer |
|
923 |
@param y: Y coordinate of mouse pointer |
|
924 |
""" |
|
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
925 |
_width, height = self.GetSize() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
926 |
|
1212 | 927 |
# Mouse is over Viewer figure and graph is not 3D |
928 |
bbox = self.GetAxesBoundingBox() |
|
929 |
if bbox.InsideXY(x, y) and not self.Is3DCanvas(): |
|
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
930 |
rect = wx.Rect(bbox.x, bbox.y, bbox.width // 2, bbox.height) |
1212 | 931 |
# Mouse is over Viewer left part of figure |
932 |
if rect.InsideXY(x, y): |
|
933 |
self.SetHighlight(HIGHLIGHT_LEFT) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
934 |
|
1212 | 935 |
# Mouse is over Viewer right part of figure |
936 |
else: |
|
937 |
self.SetHighlight(HIGHLIGHT_RIGHT) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
938 |
|
1212 | 939 |
# Mouse is over upper part of Viewer |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
940 |
elif y < height // 2: |
1212 | 941 |
# Viewer is upper one in Debug Variable Panel, show highlight |
942 |
if self.ParentWindow.IsViewerFirst(self): |
|
943 |
self.SetHighlight(HIGHLIGHT_BEFORE) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
944 |
|
1212 | 945 |
# Viewer is not the upper one, show highlight in previous one |
946 |
# It prevents highlight to move when mouse leave one Viewer to |
|
947 |
# another |
|
948 |
else: |
|
949 |
self.SetHighlight(HIGHLIGHT_NONE) |
|
950 |
self.ParentWindow.HighlightPreviousViewer(self) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
951 |
|
1212 | 952 |
# Mouse is over lower part of Viewer |
953 |
else: |
|
954 |
self.SetHighlight(HIGHLIGHT_AFTER) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
955 |
|
1212 | 956 |
def OnAxesMotion(self, event): |
957 |
""" |
|
958 |
Function overriding default function called when mouse is dragged for |
|
959 |
rotating graph preventing refresh to be called too quickly |
|
960 |
@param event: Mouse event |
|
961 |
""" |
|
962 |
if self.Is3DCanvas(): |
|
963 |
# Call default function at most 10 times per second |
|
964 |
current_time = gettime() |
|
965 |
if current_time - self.LastMotionTime > REFRESH_PERIOD: |
|
966 |
self.LastMotionTime = current_time |
|
967 |
Axes3D._on_move(self.Axes, event) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
968 |
|
1212 | 969 |
def GetAddTextFunction(self): |
970 |
""" |
|
971 |
Return function for adding text in figure according to graph type |
|
972 |
@return: Function adding text to figure |
|
973 |
""" |
|
974 |
text_func = (self.Axes.text2D if self.Is3DCanvas() else self.Axes.text) |
|
1750
acf02488f37f
clean-up: fix PEP8 E306 expected 1 blank line before a nested definition, found X
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1746
diff
changeset
|
975 |
|
1212 | 976 |
def AddText(*args, **kwargs): |
977 |
args = [0, 0, ""] |
|
978 |
kwargs["transform"] = self.Axes.transAxes |
|
979 |
return text_func(*args, **kwargs) |
|
980 |
return AddText |
|
1497
7330c85534ea
fix set_color_cycle from matplotlib deprecation warning
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1485
diff
changeset
|
981 |
|
7330c85534ea
fix set_color_cycle from matplotlib deprecation warning
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1485
diff
changeset
|
982 |
def SetAxesColor(self, color): |
1919
ccea0fa6ea91
Another set of meaningless changes to satisfy PEP8 and PyLint.
Edouard Tisserant
parents:
1878
diff
changeset
|
983 |
self.Axes.set_prop_cycle(cycler('color', color)) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
984 |
|
1212 | 985 |
def ResetGraphics(self): |
986 |
""" |
|
987 |
Reset figure and graphical elements displayed in it |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
988 |
Called any time list of items or graph type change |
1212 | 989 |
""" |
990 |
# Clear figure from any axes defined |
|
991 |
self.Figure.clear() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
992 |
|
1212 | 993 |
# Add 3D projection if graph is in 3D |
994 |
if self.Is3DCanvas(): |
|
995 |
self.Axes = self.Figure.gca(projection='3d') |
|
1497
7330c85534ea
fix set_color_cycle from matplotlib deprecation warning
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1485
diff
changeset
|
996 |
self.SetAxesColor(['b']) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
997 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
998 |
# Override function to prevent too much refresh when graph is |
1212 | 999 |
# rotated |
1000 |
self.LastMotionTime = gettime() |
|
1001 |
setattr(self.Axes, "_on_move", self.OnAxesMotion) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1002 |
|
1212 | 1003 |
# Init graph mouse event so that graph can be rotated |
1004 |
self.Axes.mouse_init() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1005 |
|
1212 | 1006 |
# Set size of Z axis labels |
1007 |
self.Axes.tick_params(axis='z', labelsize='small') |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1008 |
|
1212 | 1009 |
else: |
1010 |
self.Axes = self.Figure.gca() |
|
1497
7330c85534ea
fix set_color_cycle from matplotlib deprecation warning
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1485
diff
changeset
|
1011 |
self.SetAxesColor(COLOR_CYCLE) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1012 |
|
1212 | 1013 |
# Set size of X and Y axis labels |
1014 |
self.Axes.tick_params(axis='x', labelsize='small') |
|
1015 |
self.Axes.tick_params(axis='y', labelsize='small') |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1016 |
|
1212 | 1017 |
# Init variables storing graphical elements added to figure |
1737
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
1018 |
self.Plots = [] # List of curves |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
1019 |
self.VLine = None # Vertical line for cursor |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
1020 |
self.HLine = None # Horizontal line for cursor (only orthogonal 2D) |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
1021 |
self.AxesLabels = [] # List of items variable path text label |
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
1022 |
self.Labels = [] # List of items text label |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1023 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1024 |
# Get function to add a text in figure according to graph type |
1212 | 1025 |
add_text_func = self.GetAddTextFunction() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1026 |
|
1212 | 1027 |
# Graph type is parallel or orthogonal in 3D |
1028 |
if self.GraphType == GRAPH_PARALLEL or self.Is3DCanvas(): |
|
1029 |
num_item = len(self.Items) |
|
1030 |
for idx in xrange(num_item): |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1031 |
|
1212 | 1032 |
# Get color from color cycle (black if only one item) |
1767
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1033 |
color = ('k' if num_item == 1 else |
c74815729afd
clean-up: fix PEP8 E127 continuation line over-indented for visual indent
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1766
diff
changeset
|
1034 |
COLOR_CYCLE[idx % len(COLOR_CYCLE)]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1035 |
|
1212 | 1036 |
# In 3D graph items variable label are not displayed as text |
1037 |
# in figure, but as axis title |
|
1038 |
if not self.Is3DCanvas(): |
|
1039 |
# Items variable labels are in figure upper left corner |
|
1040 |
self.AxesLabels.append( |
|
1041 |
add_text_func(size='small', color=color, |
|
1042 |
verticalalignment='top')) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1043 |
|
1212 | 1044 |
# Items variable labels are in figure lower right corner |
1045 |
self.Labels.append( |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1046 |
add_text_func(size='large', color=color, |
1212 | 1047 |
horizontalalignment='right')) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1048 |
|
1212 | 1049 |
# Graph type is orthogonal in 2D |
1050 |
else: |
|
1051 |
# X coordinate labels are in figure lower side |
|
1052 |
self.AxesLabels.append(add_text_func(size='small')) |
|
1053 |
self.Labels.append( |
|
1054 |
add_text_func(size='large', |
|
1055 |
horizontalalignment='right')) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1056 |
|
1212 | 1057 |
# Y coordinate labels are vertical and in figure left side |
1058 |
self.AxesLabels.append( |
|
1264 | 1059 |
add_text_func(size='small', rotation='vertical', |
1060 |
verticalalignment='bottom')) |
|
1212 | 1061 |
self.Labels.append( |
1062 |
add_text_func(size='large', rotation='vertical', |
|
1063 |
verticalalignment='top')) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1064 |
|
1212 | 1065 |
# Refresh position of labels according to Viewer size |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
1066 |
_width, height = self.GetSize() |
1212 | 1067 |
self.RefreshLabelsPosition(height) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1068 |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1069 |
def RefreshLabelsPosition(self, height): |
1212 | 1070 |
""" |
1071 |
Function called when mouse leave Viewer |
|
1072 |
@param event: wx.MouseEvent |
|
1073 |
""" |
|
1074 |
# Figure position like text position in figure are expressed is ratio |
|
1075 |
# canvas size and figure size. As we want that border around figure and |
|
1076 |
# text position in figure don't change when canvas size change, we |
|
1077 |
# expressed border and text position in pixel on screen and apply the |
|
1078 |
# ratio calculated hereafter to get border and text position in |
|
1214
2ef048b5383c
Added support for opening text viewer by default and toggling between GraphicViewer and TextViewer
Laurent Bessard
parents:
1212
diff
changeset
|
1079 |
# matplotlib coordinate |
1737
a39c2918c015
clean-up: fix PEP8 E261 at least two spaces before inline comment
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1736
diff
changeset
|
1080 |
canvas_ratio = 1. / height # Divide by canvas height in pixel |
1212 | 1081 |
graph_ratio = 1. / ( |
1785
0ff2a45dcefa
clean-up: fix PEP8 W503 line break before binary operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
1082 |
(1.0 - (CANVAS_BORDER[0] + CANVAS_BORDER[1]) * canvas_ratio) * |
0ff2a45dcefa
clean-up: fix PEP8 W503 line break before binary operator
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1782
diff
changeset
|
1083 |
height) # Divide by figure height in pixel |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1084 |
|
1212 | 1085 |
# Update position of figure (keeping up and bottom border the same |
1086 |
# size) |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1087 |
self.Figure.subplotpars.update( |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
1088 |
top=1.0 - CANVAS_BORDER[1] * canvas_ratio, |
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
1089 |
bottom=CANVAS_BORDER[0] * canvas_ratio) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1090 |
|
1212 | 1091 |
# Update position of items labels |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1092 |
if self.GraphType == GRAPH_PARALLEL or self.Is3DCanvas(): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1093 |
num_item = len(self.Items) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1094 |
for idx in xrange(num_item): |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1095 |
|
1212 | 1096 |
# In 3D graph items variable label are not displayed |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1097 |
if not self.Is3DCanvas(): |
1212 | 1098 |
# Items variable labels are in figure upper left corner |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1099 |
self.AxesLabels[idx].set_position( |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1100 |
(0.05, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1101 |
1.0 - (CANVAS_PADDING + |
1212 | 1102 |
AXES_LABEL_HEIGHT * idx) * graph_ratio)) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1103 |
|
1212 | 1104 |
# Items variable labels are in figure lower right corner |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1105 |
self.Labels[idx].set_position( |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1106 |
(0.95, |
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1107 |
CANVAS_PADDING * graph_ratio + |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1108 |
(num_item - idx - 1) * VALUE_LABEL_HEIGHT * graph_ratio)) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1109 |
else: |
1212 | 1110 |
# X coordinate labels are in figure lower side |
1111 |
self.AxesLabels[0].set_position( |
|
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1112 |
(0.1, CANVAS_PADDING * graph_ratio)) |
1212 | 1113 |
self.Labels[0].set_position( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1114 |
(0.95, CANVAS_PADDING * graph_ratio)) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1115 |
|
1212 | 1116 |
# Y coordinate labels are vertical and in figure left side |
1117 |
self.AxesLabels[1].set_position( |
|
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1118 |
(0.05, 2 * CANVAS_PADDING * graph_ratio)) |
1212 | 1119 |
self.Labels[1].set_position( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1120 |
(0.05, 1.0 - CANVAS_PADDING * graph_ratio)) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1121 |
|
1212 | 1122 |
# Update subplots |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1123 |
self.Figure.subplots_adjust() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1124 |
|
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1125 |
def RefreshViewer(self, refresh_graphics=True): |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1126 |
""" |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1127 |
Function called to refresh displayed by matplotlib canvas |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1128 |
@param refresh_graphics: Flag indicating that graphs have to be |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1129 |
refreshed (False: only label values have to be refreshed) |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1130 |
""" |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1131 |
# Refresh graphs if needed |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1132 |
if refresh_graphics: |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1133 |
# Get tick range of values to display |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1134 |
start_tick, end_tick = self.ParentWindow.GetRange() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1135 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1136 |
# Graph is parallel |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1137 |
if self.GraphType == GRAPH_PARALLEL: |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1138 |
# Init list of data range for each variable displayed |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1139 |
ranges = [] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1140 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1141 |
# Get data and range for each variable displayed |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1142 |
for idx, item in enumerate(self.Items): |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1143 |
data, min_value, max_value = item.GetDataAndValueRange( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1144 |
start_tick, end_tick, not self.ZoomFit) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1145 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1146 |
# Check that data is not empty |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1147 |
if data is not None: |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1148 |
# Add variable range to list of variable data range |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1149 |
ranges.append((min_value, max_value)) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1150 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1151 |
# Add plot to canvas if not yet created |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1152 |
if len(self.Plots) <= idx: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1153 |
self.Plots.append( |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1154 |
self.Axes.plot(data[:, 0], data[:, 1])[0]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1155 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1156 |
# Set data to already created plot in canvas |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1157 |
else: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1158 |
self.Plots[idx].set_data(data[:, 0], data[:, 1]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1159 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1160 |
# Get X and Y axis ranges |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1161 |
x_min, x_max = start_tick, end_tick |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1162 |
y_min, y_max = merge_ranges(ranges) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1163 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1164 |
# Display cursor in canvas if a cursor tick is defined and it is |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1165 |
# include in values tick range |
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1764
diff
changeset
|
1166 |
if self.CursorTick is not None and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1764
diff
changeset
|
1167 |
start_tick <= self.CursorTick <= end_tick: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1168 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1169 |
# Define a vertical line to display cursor position if no |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1170 |
# line is already defined |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1171 |
if self.VLine is None: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1172 |
self.VLine = self.Axes.axvline(self.CursorTick, |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1173 |
color=CURSOR_COLOR) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1174 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1175 |
# Set value of vertical line if already defined |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1176 |
else: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1177 |
self.VLine.set_xdata((self.CursorTick, self.CursorTick)) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1178 |
self.VLine.set_visible(True) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1179 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1180 |
# Hide vertical line if cursor tick is not defined or reset |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1181 |
elif self.VLine is not None: |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1182 |
self.VLine.set_visible(False) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1183 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1184 |
# Graph is orthogonal |
929
c562031146e4
Improved matplotlib graphic debug panel implementation
Laurent Bessard
parents:
928
diff
changeset
|
1185 |
else: |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1186 |
# Update tick range, removing ticks that don't have a value for |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1187 |
# each variable |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1188 |
start_tick = max(start_tick, self.GetItemsMinCommonTick()) |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1189 |
end_tick = max(end_tick, start_tick) |
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
1190 |
items = self.ItemsDict.values() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1191 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1192 |
# Get data and range for first variable (X coordinate) |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1193 |
x_data, x_min, x_max = items[0].GetDataAndValueRange( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1194 |
start_tick, end_tick, not self.ZoomFit) |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1195 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1196 |
# Get data and range for second variable (Y coordinate) |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1197 |
y_data, y_min, y_max = items[1].GetDataAndValueRange( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1198 |
start_tick, end_tick, not self.ZoomFit) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1199 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1200 |
# Normalize X and Y coordinates value range |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1201 |
x_min, x_max = merge_ranges([(x_min, x_max)]) |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1202 |
y_min, y_max = merge_ranges([(y_min, y_max)]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1203 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1204 |
# Get X and Y coordinates for cursor if cursor tick is defined |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1205 |
if self.CursorTick is not None: |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
1206 |
x_cursor, _x_forced = items[0].GetValue( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1207 |
self.CursorTick, raw=True) |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
1208 |
y_cursor, _y_forced = items[1].GetValue( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1209 |
self.CursorTick, raw=True) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1210 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1211 |
# Get common data length so that each value has an x and y |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1212 |
# coordinate |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1213 |
length = (min(len(x_data), len(y_data)) |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1214 |
if x_data is not None and y_data is not None |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1215 |
else 0) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1216 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1217 |
# Graph is orthogonal 2D |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1218 |
if len(self.Items) < 3: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1219 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1220 |
# Check that x and y data are not empty |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1221 |
if x_data is not None and y_data is not None: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1222 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1223 |
# Add plot to canvas if not yet created |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1224 |
if len(self.Plots) == 0: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1225 |
self.Plots.append( |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1226 |
self.Axes.plot(x_data[:, 1][:length], |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1227 |
y_data[:, 1][:length])[0]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1228 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1229 |
# Set data to already created plot in canvas |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1230 |
else: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1231 |
self.Plots[0].set_data( |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1232 |
x_data[:, 1][:length], |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1233 |
y_data[:, 1][:length]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1234 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1235 |
# Display cursor in canvas if a cursor tick is defined and it is |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1236 |
# include in values tick range |
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1764
diff
changeset
|
1237 |
if self.CursorTick is not None and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1764
diff
changeset
|
1238 |
start_tick <= self.CursorTick <= end_tick: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1239 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1240 |
# Define a vertical line to display cursor x coordinate |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1241 |
# if no line is already defined |
924
5f2cc382be8c
Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents:
919
diff
changeset
|
1242 |
if self.VLine is None: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1243 |
self.VLine = self.Axes.axvline(x_cursor, |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1244 |
color=CURSOR_COLOR) |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1245 |
# Set value of vertical line if already defined |
924
5f2cc382be8c
Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents:
919
diff
changeset
|
1246 |
else: |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1247 |
self.VLine.set_xdata((x_cursor, x_cursor)) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1248 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1249 |
# Define a horizontal line to display cursor y |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1250 |
# coordinate if no line is already defined |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1251 |
if self.HLine is None: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1252 |
self.HLine = self.Axes.axhline(y_cursor, |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1253 |
color=CURSOR_COLOR) |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1254 |
# Set value of horizontal line if already defined |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1255 |
else: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1256 |
self.HLine.set_ydata((y_cursor, y_cursor)) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1257 |
|
924
5f2cc382be8c
Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents:
919
diff
changeset
|
1258 |
self.VLine.set_visible(True) |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1259 |
self.HLine.set_visible(True) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1260 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1261 |
# Hide vertical and horizontal line if cursor tick is not |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1262 |
# defined or reset |
924
5f2cc382be8c
Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents:
919
diff
changeset
|
1263 |
else: |
5f2cc382be8c
Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents:
919
diff
changeset
|
1264 |
if self.VLine is not None: |
5f2cc382be8c
Added support for displaying string variables variations in a graph and cursor on graphs
Laurent Bessard
parents:
919
diff
changeset
|
1265 |
self.VLine.set_visible(False) |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1266 |
if self.HLine is not None: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1267 |
self.HLine.set_visible(False) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1268 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1269 |
# Graph is orthogonal 3D |
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:
912
diff
changeset
|
1270 |
else: |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1271 |
# Remove all plots already defined in 3D canvas |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1272 |
while len(self.Axes.lines) > 0: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1273 |
self.Axes.lines.pop() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1274 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1275 |
# Get data and range for third variable (Z coordinate) |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1276 |
z_data, z_min, z_max = items[2].GetDataAndValueRange( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1277 |
start_tick, end_tick, not self.ZoomFit) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1278 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1279 |
# Normalize Z coordinate value range |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1280 |
z_min, z_max = merge_ranges([(z_min, z_max)]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1281 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1282 |
# Check that x, y and z data are not empty |
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1764
diff
changeset
|
1283 |
if x_data is not None and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1764
diff
changeset
|
1284 |
y_data is not None and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1764
diff
changeset
|
1285 |
z_data is not None: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1286 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1287 |
# Get common data length so that each value has an x, y |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1288 |
# and z coordinate |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1289 |
length = min(length, len(z_data)) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1290 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1291 |
# Add plot to canvas |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1292 |
self.Axes.plot(x_data[:, 1][:length], |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1293 |
y_data[:, 1][:length], |
1744
69dfdb26f600
clean-up: fix PEP8 E251 unexpected spaces around keyword / parameter equals
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1741
diff
changeset
|
1294 |
zs=z_data[:, 1][:length]) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1295 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1296 |
# Display cursor in canvas if a cursor tick is defined and |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1297 |
# it is include in values tick range |
1766
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1764
diff
changeset
|
1298 |
if self.CursorTick is not None and \ |
c1e5b9f19483
clean-up: fix PEP8 E129 visually indented line with same indent as next logical line
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1764
diff
changeset
|
1299 |
start_tick <= self.CursorTick <= end_tick: |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1300 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1301 |
# Get Z coordinate for cursor |
1847
6198190bc121
explicitly mark unused variables found by pylint with _ or dummy
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1832
diff
changeset
|
1302 |
z_cursor, _z_forced = items[2].GetValue( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1303 |
self.CursorTick, raw=True) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1304 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1305 |
# Add 3 lines parallel to x, y and z axis to display |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1306 |
# cursor position in 3D |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1307 |
for kwargs in [{"xs": numpy.array([x_min, x_max])}, |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1308 |
{"ys": numpy.array([y_min, y_max])}, |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1309 |
{"zs": numpy.array([z_min, z_max])}]: |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1310 |
for param, value in [ |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1311 |
("xs", numpy.array([x_cursor, x_cursor])), |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1312 |
("ys", numpy.array([y_cursor, y_cursor])), |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1313 |
("zs", numpy.array([z_cursor, z_cursor]))]: |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1314 |
kwargs.setdefault(param, value) |
1200
501cb0bb4c05
Splitted DebugVariableGraphicPanel.py into several files
Laurent Bessard
parents:
1199
diff
changeset
|
1315 |
kwargs["color"] = CURSOR_COLOR |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1316 |
self.Axes.plot(**kwargs) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1317 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1318 |
# Set Z axis limits |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1319 |
self.Axes.set_zlim(z_min, z_max) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1320 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1321 |
# Set X and Y axis limits |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1322 |
self.Axes.set_xlim(x_min, x_max) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1323 |
self.Axes.set_ylim(y_min, y_max) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1324 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1325 |
# Get value and forced flag for each variable displayed in graph |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1326 |
# If cursor tick is not defined get value and flag of last received |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1327 |
# or get value and flag of variable at cursor tick |
2440
45b43f275ca1
python3 support: pylint, W1601 # (apply-builtin) apply built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
1328 |
args = [( |
1878
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1329 |
item.GetValue(self.CursorTick) |
fb73a6b6622d
fix pylint warning '(bad-continuation) Wrong hanging indentation before block'
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1853
diff
changeset
|
1330 |
if self.CursorTick is not None |
2440
45b43f275ca1
python3 support: pylint, W1601 # (apply-builtin) apply built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
1331 |
else (item.GetValue(), item.IsForced())) for item in self.Items] |
45b43f275ca1
python3 support: pylint, W1601 # (apply-builtin) apply built-in referenced
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2437
diff
changeset
|
1332 |
values, forced = zip(*args) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1333 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1334 |
# Get path of each variable displayed simplified using panel variable |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1335 |
# name mask |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1336 |
labels = [item.GetVariable(self.ParentWindow.GetVariableNameMask()) |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1337 |
for item in self.Items] |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1338 |
|
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1339 |
# Get style for each variable according to |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1340 |
styles = map(lambda x: {True: 'italic', False: 'normal'}[x], forced) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1341 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1342 |
# Graph is orthogonal 3D, set variables path as 3D axis label |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1343 |
if self.Is3DCanvas(): |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1344 |
for idx, label_func in enumerate([self.Axes.set_xlabel, |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1345 |
self.Axes.set_ylabel, |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1346 |
self.Axes.set_zlabel]): |
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1347 |
label_func(labels[idx], fontdict={'size': 'small', |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1348 |
'color': COLOR_CYCLE[idx]}) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1349 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1350 |
# Graph is not orthogonal 3D, set variables path in axes labels |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1351 |
else: |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1352 |
for label, text in zip(self.AxesLabels, labels): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1353 |
label.set_text(text) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1354 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1355 |
# Set value label text and style according to value and forced flag for |
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1356 |
# each variable displayed |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1357 |
for label, value, style in zip(self.Labels, values, styles): |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1358 |
label.set_text(value) |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1359 |
label.set_style(style) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1360 |
|
1267
fae0809eae98
Added support for zooming graph so that it fits canvas size in Debug Variable Panel
Laurent Bessard
parents:
1264
diff
changeset
|
1361 |
# Refresh figure |
1198
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1362 |
self.draw() |
8b4e6bd0aa92
Separated old table debug variable panel and new graphic debug variable panel
Laurent Bessard
parents:
1194
diff
changeset
|
1363 |
|
1209 | 1364 |
def draw(self, drawDC=None): |
1365 |
""" |
|
1366 |
Render the figure. |
|
1367 |
""" |
|
1368 |
# Render figure using agg |
|
1369 |
FigureCanvasAgg.draw(self) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1370 |
|
1209 | 1371 |
# Get bitmap of figure rendered |
1372 |
self.bitmap = _convert_agg_to_wx_bitmap(self.get_renderer(), None) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1373 |
if wx.VERSION < (3, 0, 0): |
1485
a30776c43846
bitmap in wx3.0 doesn't have useAlpha() method
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1362
diff
changeset
|
1374 |
self.bitmap.UseAlpha() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1375 |
|
1209 | 1376 |
# Create DC for rendering graphics in bitmap |
1377 |
destDC = wx.MemoryDC() |
|
1378 |
destDC.SelectObject(self.bitmap) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1379 |
|
1209 | 1380 |
# Get Graphics Context for DC, for anti-aliased and transparent |
1381 |
# rendering |
|
1382 |
destGC = wx.GCDC(destDC) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1383 |
|
1209 | 1384 |
destGC.BeginDrawing() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1385 |
|
1209 | 1386 |
# Get canvas size and figure bounding box in canvas |
1387 |
width, height = self.GetSize() |
|
1388 |
bbox = self.GetAxesBoundingBox() |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1389 |
|
1209 | 1390 |
# If highlight to display is resize, draw thick grey line at bottom |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1391 |
# side of canvas |
1209 | 1392 |
if self.Highlight == HIGHLIGHT_RESIZE: |
1823
1e9a67d68612
fix commit "lazy initialization of highlight pens and brushes
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1785
diff
changeset
|
1393 |
destGC.SetPen(HIGHLIGHT['RESIZE_PEN']) |
1e9a67d68612
fix commit "lazy initialization of highlight pens and brushes
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1785
diff
changeset
|
1394 |
destGC.SetBrush(HIGHLIGHT['RESIZE_BRUSH']) |
1209 | 1395 |
destGC.DrawRectangle(0, height - 5, width, 5) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1396 |
|
1209 | 1397 |
# If highlight to display is merging graph, draw 50% transparent blue |
1398 |
# rectangle on left or right part of figure depending on highlight type |
|
1399 |
elif self.Highlight in [HIGHLIGHT_LEFT, HIGHLIGHT_RIGHT]: |
|
1823
1e9a67d68612
fix commit "lazy initialization of highlight pens and brushes
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1785
diff
changeset
|
1400 |
destGC.SetPen(HIGHLIGHT['DROP_PEN']) |
1e9a67d68612
fix commit "lazy initialization of highlight pens and brushes
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1785
diff
changeset
|
1401 |
destGC.SetBrush(HIGHLIGHT['DROP_BRUSH']) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1402 |
|
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
1403 |
x_offset = (bbox.width // 2 |
1209 | 1404 |
if self.Highlight == HIGHLIGHT_RIGHT |
1405 |
else 0) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1406 |
destGC.DrawRectangle(bbox.x + x_offset, bbox.y, |
2437
105c20fdeb19
python3 support: pylint, W1619 #(old-division) division w/o __future__ statement
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
2432
diff
changeset
|
1407 |
bbox.width // 2, bbox.height) |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1408 |
|
1209 | 1409 |
# Draw other Viewer common elements |
1410 |
self.DrawCommonElements(destGC, self.GetButtons()) |
|
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1411 |
|
1209 | 1412 |
destGC.EndDrawing() |
1730
64d8f52bc8c8
clean-up for PEP8: fix W291 trailing whitespace
Andrey Skvortsov <andrej.skvortzov@gmail.com>
parents:
1571
diff
changeset
|
1413 |
|
1209 | 1414 |
self._isDrawn = True |
1415 |
self.gui_repaint(drawDC=drawDC) |