An error occurred while loading the file. Please try again.
-
Pierre-Antoine Rouby authoredc3954208
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
# -*- coding: utf-8 -*-
from tools import timer
from View.Plot.APlot import APlot
from PyQt5.QtCore import (
QCoreApplication
)
_translate = QCoreApplication.translate
class PlotKPC(APlot):
def __init__(self, canvas=None, data=None, toolbar=None):
super(PlotKPC, self).__init__(
canvas=canvas,
data=data,
toolbar=toolbar
)
self.line_kp_zgl = []
self.line_kp_zmin = None
self.line_kp_zmin_zmax = None
self.before_plot_selected = None
self.plot_selected = None
self.after_plot_selected = None
@timer
def draw(self):
self.canvas.axes.cla()
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
self.canvas.axes.set_xlabel(
_translate("MainWindow_reach", "Kp (m)"),
color='green', fontsize=12
)
self.canvas.axes.set_ylabel(
_translate("MainWindow_reach", "Cote (m)"),
color='green', fontsize=12
)
kp = self.data.get_kp()
z_min = self.data.get_z_min()
z_max = self.data.get_z_max()
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
x=kp,
ymin=z_min, ymax=z_max,
color='r', lw=1.
)
self.plot_selected, = self.canvas.axes.plot(
(kp[0], kp[0]),
(z_min[0], z_max[0]),
color='b', lw=1.8
)
self.plot_selected.set_visible(False)
self.before_plot_selected, = self.canvas.axes.plot(
(kp[0], kp[0]),
(z_min[0], z_max[0]),
color='k', lw=1.6, linestyle='--'
)
self.before_plot_selected.set_visible(False)
self.after_plot_selected, = self.canvas.axes.plot(
(kp[0], kp[0]),
(z_min[0], z_max[0]),
color='m', lw=1.6, linestyle='--'
)
self.after_plot_selected.set_visible(False)
kp = self.data.get_kp()
self.line_kp_zgl = []
for z in self.data.get_guidelines_z():
# Is incomplete guideline?
if len(z) != len(kp):
continue
self.line_kp_zgl.append(
self.canvas.axes.plot(
kp, z, lw=1.
)
)
self.line_kp_zmin, = self.canvas.axes.plot(
kp, z_min,
linestyle=":", lw=1.8,
color='lightgrey'
)
self.canvas.figure.tight_layout()
self.canvas.figure.canvas.draw_idle()
self.toolbar.update()
@timer
def update(self, ind=None):
if ind is not None:
before = ind - 1
after = ind + 1
self.before_plot_selected.set_visible(False)
self.plot_selected.set_visible(False)
self.after_plot_selected.set_visible(False)
if 0 <= before < self.data.number_profiles:
kp_i = self.data.profile(before).kp
z_min_i = self.data.profile(before).z_min()
z_max_i = self.data.profile(before).z_max()
self.before_plot_selected.set_data(
(kp_i, kp_i),
(z_min_i, z_max_i)
)
self.before_plot_selected.set_visible(True)
if 0 <= ind < self.data.number_profiles:
kp_i = self.data.profile(ind).kp
z_min_i = self.data.profile(ind).z_min()
z_max_i = self.data.profile(ind).z_max()
self.plot_selected.set_data(
(kp_i, kp_i),
(z_min_i, z_max_i)
)
self.plot_selected.set_visible(True)
if 0 <= after < self.data.number_profiles:
kp_i = self.data.profile(after).kp
z_min_i = self.data.profile(after).z_min()
z_max_i = self.data.profile(after).z_max()
self.after_plot_selected.set_data(
(kp_i, kp_i),
(z_min_i, z_max_i)
)
self.after_plot_selected.set_visible(True)
self.canvas.figure.canvas.draw_idle()
else:
kp = self.data.get_kp()
z_min = self.data.get_z_min()
z_max = self.data.get_z_max()
self.line_kp_zmin.set_data(kp, z_min)
self.line_kp_zmin_zmax.remove()
self.line_kp_zmin_zmax = self.canvas.axes.vlines(
x=kp,
ymin=z_min, ymax=z_max,
color='r', lw=1.
)
z_complete = self.data.get_guidelines_z()
try:
for i in range(len(self.line_kp_zgl)):
self.line_kp_zgl[i][0].set_data(
kp, z_complete[i]
)
except Exception as e:
print(f"Failed to update graphic 2: {e}")
self.canvas.axes.autoscale_view(True, True, True)
self.canvas.figure.canvas.draw_idle()