An error occurred while loading the file. Please try again.
-
Narcon Nicolas authored2790d13e
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
# -*- coding: utf-8 -*-
import logging
from tools import timer, trace
from View.Plot.APlot import APlot
from View.Plot.mpl_canvas_onpick_event import OnpickEvent
from PyQt5.QtCore import (
QCoreApplication
)
_translate = QCoreApplication.translate
logger = logging.getLogger()
class Plot(APlot):
def __init__(self, canvas=None, data=None, toolbar=None, table=None):
super(Plot, self).__init__(
canvas=canvas,
data=data,
toolbar=toolbar
)
self._table = table
self.line_xy = []
self.line_gl = []
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
)
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='r', lw=1.5,
markersize=7, marker='+',
picker=30
)
self.canvas.axes.set_xlabel(
_translate("MainWindowProfile",
"Abscisse en travers (m)"),
color='black', fontsize=10
)
self.canvas.axes.set_ylabel(
_translate("MainWindowProfile", "Cote (m)"),
color='black', fontsize=10
)
# 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.canvas.figure.tight_layout()
self.canvas.figure.canvas.draw_idle()
@timer
def update(self, ind=None):
logger.info("TODO: implemente update")
self.draw()