An error occurred while loading the file. Please try again.
-
Pierre-Antoine Rouby authorede215e0f1
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
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
# MainWindowTabInfo.py -- Pamhyr
# Copyright (C) 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.PamhyrWidget import PamhyrWidget
logger = logging.getLogger()
class WidgetInfo(PamhyrWidget):
_pamhyr_ui = "MainWindowTabInfo"
color_grey = "<font color='grey'>"
color_end = "</font>"
def __init__(self, study=None, parent=None):
self._study = study
super(WidgetInfo, self).__init__(
parent=parent
)
self.set_initial_values()
@property
def study(self):
return self._study
@study.setter
def study(self, study):
self._study = study
def set_initial_values(self):
self.set_label_text("label_study_name", "")
self.set_text_edit_text("textBrowser_study", "")
self.set_label_text("label_current_reach", "None")
self.set_label_text("label_nodes", "-")
self.set_label_text("label_edges", "-")
self.set_label_text("label_cs", "-")
self.set_label_text("label_points", "-")
self.set_label_text("label_res", "-")
self.set_label_text("label_bc", "-")
self.set_label_text("label_lc", "-")
self.set_label_text("label_hs", "-")
def update(self):
if self._study is None:
self.set_initial_values()
return
self.set_label_text("label_study_name", self._study.name)
self.set_text_edit_text("textBrowser_study", self._study.description)
self.set_network_values()
self.set_geometry_values()
def set_network_values(self):
river = self._study.river
n_nodes = river.enable_nodes_counts()
n_d_nodes = river.nodes_counts() - n_nodes
n_edges = river.enable_edges_counts()
n_d_edges = river.edges_counts() - n_edges
self.set_label_text(
"label_nodes",
f"{n_nodes} {self.color_grey}({n_d_nodes}){self.color_end}"
)
self.set_label_text(
"label_edges",
f"{n_edges} {self.color_grey}({n_d_edges}){self.color_end}"
)
current = river.current_reach()
if current is not None:
name = current.reach.name
else:
name = "None"
self.set_label_text("label_current_reach", name)
self.set_network_values_ext(river)
def set_network_values_ext(self, river):
self.set_network_values_ext_reservoir(river)
self.set_network_values_ext_bc(river)
self.set_network_values_ext_lc(river)
def set_network_values_ext_reservoir(self, river):
n_res = 0
n_na_res = 0
for res in river.reservoir.lst:
if res.node is not None:
n_res += 1
else:
n_na_res += 1
self.set_label_text(
"label_res",
f"{n_res} {self.color_grey}({n_na_res}){self.color_end}"
)
def set_network_values_ext_bc(self, river):
bc = river.boundary_condition
n_bc = 0
n_na_bc = 0
for tab in bc._tabs_list:
for c in bc.get_tab(tab):
if c.node is not None:
n_bc += 1
else:
n_na_bc += 1
self.set_label_text(
"label_bc",
f"{n_bc} {self.color_grey}({n_na_bc}){self.color_end}"
)
def set_network_values_ext_lc(self, river):
lc = river.lateral_contribution
n_lc = 0
n_na_lc = 0
for tab in lc._tabs_list:
for c in lc.get_tab(tab):
if c.edge is not None:
n_lc += 1
else:
n_na_lc += 1
self.set_label_text(
"label_lc",
f"{n_lc} {self.color_grey}({n_na_lc}){self.color_end}"
)
def set_geometry_values(self):
river = self._study.river
n_cs = 0
n_d_cs = 0
n_points = 0
n_d_points = 0
for edge in river.edges():
for profile in edge.reach.profiles:
if edge.is_enable():
n_points += len(profile)
n_cs += 1
else:
n_d_points += len(profile)
n_d_cs += 1
self.set_label_text(
"label_cs",
f"{n_cs} {self.color_grey}({n_d_cs}){self.color_end}"
)
self.set_label_text(
"label_points",
f"{n_points} {self.color_grey}({n_d_points}){self.color_end}"
)
self.set_geometry_values_ext(river)
def set_geometry_values_ext(self, river):
self.set_geometry_values_ext_hs(river)
def set_geometry_values_ext_hs(self, river):
hs = river.hydraulic_structures
n_hs = 0
n_na_hs = 0
for h in hs.lst:
if h.input_reach is not None and h.input_kp is not None:
n_hs += 1
else:
n_na_hs += 1
self.set_label_text(
"label_hs",
f"{n_hs} {self.color_grey}({n_na_hs}){self.color_end}"
)