An error occurred while loading the file. Please try again.
-
Pierre-Antoine Rouby authored2e158f4c
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
# Plot.py -- Pamhyr
# Copyright (C) 2023-2024 INRAE
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
# -*- coding: utf-8 -*-
import logging
from tools import timer, trace
from View.Tools.PamhyrPlot import PamhyrPlot
from View.Tools.Plot.OnPickEvent import OnpickEvent
from PyQt5.QtCore import (
QCoreApplication
)
_translate = QCoreApplication.translate
logger = logging.getLogger()
class Plot(PamhyrPlot):
def __init__(self, canvas=None, trad=None, data=None, toolbar=None,
table=None, parent=None):
super(Plot, self).__init__(
canvas=canvas,
trad=trad,
data=data,
toolbar=toolbar,
parent=parent
)
self._table = table
self.line_xy = []
self.line_gl = []
self.label_x = self._trad["unit_kp"]
self.label_y = self._trad["unit_height"]
self.before_plot_selected = None
self.plot_selected = None
self.after_plot_selected = None
self._isometric_axis = False
@timer
def draw(self):
self.init_axes()
x = self.data.get_station()
y = self.data.z()
x_carto = self.data.x()
y_carto = self.data.y()
if (len(x_carto) < 3 or len(y_carto) < 3 or
len(x) < 3):
# Noting to do in this case
return
gl = map(lambda p: p.name, self.data.points)
self.profile_line2D, = self.canvas.axes.plot(
x, y, color=self.color_plot,
lw=1.5, markersize=7, marker='+',
picker=30
)
# Add label on graph
self.annotation = []
for i, name in enumerate(list(gl)):
annotation = self.canvas.axes.annotate(
name, (x[i], y[i]),
horizontalalignment='left',
verticalalignment='top',
annotation_clip=True,
fontsize=10, color='black'
)
annotation.set_position((x[i], y[i]))
annotation.set_color("black")
self.annotation.append(annotation)
al = 8.
arrowprops = dict(
clip_on=True,
headwidth=5.,
facecolor='k'
)
kwargs = dict(
xycoords='axes fraction',
textcoords='offset points',
arrowprops=arrowprops,
)
self.canvas.axes.annotate("", (1, 0), xytext=(-al, 0), **kwargs)
self.canvas.axes.annotate("", (0, 1), xytext=(0, -al), **kwargs)
self.canvas.axes.spines[['top', 'right']].set_color('none')
self.canvas.axes.yaxis.tick_left()
self.canvas.axes.xaxis.tick_bottom()
self.canvas.axes.set_facecolor('#F9F9F9')
self.canvas.figure.patch.set_facecolor('white')
self.onpick_event = OnpickEvent(
self.canvas.axes,
x, y, x_carto, y_carto,
self._table
)
self.canvas.figure.canvas\
.mpl_connect(
'pick_event',
self.onpick_event.onpick
)
self.onclick_event = OnpickEvent(
self.canvas.axes,
x, y, x_carto, y_carto,
self._table
)
self.canvas.figure.canvas\
.mpl_connect(
'button_press_event',
self.onclick_event.onclick
)
self.idle()
@timer
def update(self):
self.draw()