Failed to fetch fork details. Try again later.
-
Delaigue Olivier authored90b8fbad
Forked from
HYCAR-Hydro / airGR
Source project has a limited visibility.
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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
# -*- coding: utf-8 -*-
from tools import timer, trace
from View.Plot.APlot import APlot
from PyQt5.QtCore import (
QCoreApplication
)
_translate = QCoreApplication.translate
class PlotXY(APlot):
def __init__(self, canvas=None, data=None, toolbar=None, display_current=True):
super(PlotXY, self).__init__(
canvas=canvas,
data=data,
toolbar=toolbar
)
self.display_current = display_current
self.line_xy = []
self.line_gl = []
self.before_plot_selected = None
self.plot_selected = None
self.after_plot_selected = None
@timer
def draw(self, highlight=None):
self.canvas.axes.cla()
self.canvas.axes.grid(color='grey', linestyle='--', linewidth=0.5)
if self.data is None:
return
if self.data.number_profiles == 0:
self._init = False
return
kp_min, kp_max = (-1, -1)
if highlight is not None:
kp_min, kp_max = highlight
# Axes
self.canvas.axes.set_xlabel(
_translate("MainWindow_reach", "X (m)"),
color='green', fontsize=12
)
self.canvas.axes.set_ylabel(
_translate("MainWindow_reach", "Y (m)"),
color='green', fontsize=12
)
# Draw line for each profile
self.line_xy = [
self.canvas.axes.plot(
x, y, lw=1.,
color='b' if kp_min <= kp <= kp_max else 'r',
markersize=3, marker='+'
)
for x, y, kp in zip(
self.data.get_x(), self.data.get_y(),
self.data.get_kp()
)
]
# Guide lines
x_complete = self.data.get_guidelines_x()
y_complete = self.data.get_guidelines_y()
self.line_gl = [
self.canvas.axes.plot(
x, y,
)
for x, y in zip(x_complete, y_complete)
]
if self.display_current:
# Previous profile
self.before_plot_selected, = self.canvas.axes.plot(
self.data.profile(0).x(),
self.data.profile(0).y(),
lw=1., markersize=3,
marker='+', color="k", linestyle="--"
)
self.before_plot_selected.set_visible(False)
# Current profile
self.plot_selected, = self.canvas.axes.plot(
self.data.profile(0).x(),
self.data.profile(0).y(),
lw=1., markersize=3,
marker='+', color="b"
)
self.plot_selected.set_visible(False)
# Next profile
self.after_plot_selected, = self.canvas.axes.plot(
self.data.profile(0).x(),
self.data.profile(0).y(),
lw=1., markersize=3,
marker='+', color="m", linestyle='--'
)
self.after_plot_selected.set_visible(False)
self.canvas.axes.autoscale_view(True, True, True)
self.canvas.axes.autoscale()
self.canvas.figure.tight_layout()
self.canvas.figure.canvas.draw_idle()
self.toolbar.update()
self._init = True
@timer
def update(self, ind=None):
if self._init == False:
self.draw()
return
if self.data is None:
return
self.data.compute_guidelines()
x_complete = self.data.get_guidelines_x()
y_complete = self.data.get_guidelines_y()
for i in range(self.data.number_profiles):
if i < len(self.line_xy):
self.line_xy[i][0].set_data(
self.data.profile(i).x(),
self.data.profile(i).y()
)
else:
self.line_xy.append(
self.canvas.axes.plot(
self.data.profile(i).x(),
self.data.profile(i).y(),
lw=1., color='r',
markersize=3, marker='+'
)
)
for i in range(len(x_complete)):
if i < len(self.line_gl):
self.line_gl[i][0].set_data(
x_complete[i],
y_complete[i]
)
else:
self.line_gl.append(
self.canvas.axes.plot(
x_complete[i],
y_complete[i]
)
)
if ind is not None and self.display_current:
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:
self.before_plot_selected.set_data(self.data.profile(before).x(),
self.data.profile(before).y())
self.before_plot_selected.set_visible(True)
if 0 <= ind < self.data.number_profiles:
self.plot_selected.set_data(self.data.profile(ind).x(),
self.data.profile(ind).y())
self.plot_selected.set_visible(True)
if 0 <= after < self.data.number_profiles:
self.after_plot_selected.set_data(self.data.profile(after).x(),
self.data.profile(after).y())
self.after_plot_selected.set_visible(True)
self.canvas.axes.relim()
self.canvas.axes.autoscale()
self.canvas.axes.autoscale_view()
self.canvas.figure.tight_layout()
self.canvas.figure.canvas.draw_idle()