wolfhece 2.2.2__py3-none-any.whl → 2.2.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- wolfhece/PandasGrid.py +67 -0
- wolfhece/PyDraw.py +732 -34
- wolfhece/PyGui.py +6 -2
- wolfhece/PyPalette.py +10 -0
- wolfhece/PyVertex.py +15 -2
- wolfhece/PyWMS.py +72 -3
- wolfhece/acceptability/acceptability_gui.py +99 -155
- wolfhece/acceptability/func.py +88 -8
- wolfhece/apps/check_install.py +6 -6
- wolfhece/apps/splashscreen.py +5 -0
- wolfhece/apps/version.py +1 -1
- wolfhece/assets/__init__.py +1 -0
- wolfhece/assets/speedometer.py +135 -0
- wolfhece/dike.py +684 -0
- wolfhece/drowning_victims/__init__.py +0 -0
- wolfhece/drowning_victims/drowning_class.py +2124 -0
- wolfhece/drowning_victims/drowning_functions.py +1019 -0
- wolfhece/lifewatch.py +88 -0
- wolfhece/scenario/config_manager.py +4 -4
- wolfhece/wolf_array.py +34 -11
- wolfhece/wolf_texture.py +9 -2
- {wolfhece-2.2.2.dist-info → wolfhece-2.2.4.dist-info}/METADATA +3 -1
- {wolfhece-2.2.2.dist-info → wolfhece-2.2.4.dist-info}/RECORD +26 -18
- {wolfhece-2.2.2.dist-info → wolfhece-2.2.4.dist-info}/WHEEL +0 -0
- {wolfhece-2.2.2.dist-info → wolfhece-2.2.4.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.2.2.dist-info → wolfhece-2.2.4.dist-info}/top_level.txt +0 -0
wolfhece/PyDraw.py
CHANGED
@@ -7,6 +7,11 @@ Copyright (c) 2024 University of Liege. All rights reserved.
|
|
7
7
|
This script and its content are protected by copyright law. Unauthorized
|
8
8
|
copying or distribution of this file, via any medium, is strictly prohibited.
|
9
9
|
"""
|
10
|
+
try:
|
11
|
+
from osgeo import gdal
|
12
|
+
except ImportError as e:
|
13
|
+
print(e)
|
14
|
+
raise ImportError("I can't find the 'gdal' package. You should get it from https://www.lfd.uci.edu/~gohlke/pythonlibs/")
|
10
15
|
|
11
16
|
try:
|
12
17
|
import numpy as np
|
@@ -24,24 +29,18 @@ try:
|
|
24
29
|
import json
|
25
30
|
import glob
|
26
31
|
import traceback
|
27
|
-
from datetime import datetime
|
32
|
+
from datetime import datetime
|
28
33
|
from sklearn import linear_model, datasets
|
29
34
|
|
30
35
|
except ImportError as e:
|
31
36
|
print(e)
|
32
37
|
raise ImportError("Error importing wxPython, numpy, PIL, json, glob, traceback, sklearn. Please check your installation.")
|
33
38
|
|
34
|
-
try:
|
35
|
-
from osgeo import gdal
|
36
|
-
except ModuleNotFoundError:
|
37
|
-
raise Exception("I can't find the 'gdal' package. You should get it from https://www.lfd.uci.edu/~gohlke/pythonlibs/")
|
38
|
-
|
39
39
|
try:
|
40
40
|
from time import sleep
|
41
41
|
from datetime import timedelta
|
42
42
|
from multiprocessing import Pool
|
43
43
|
from pathlib import Path
|
44
|
-
from time import sleep
|
45
44
|
except ImportError as e:
|
46
45
|
print(e)
|
47
46
|
raise ImportError("Error importing time, datetime, multiprocessing, pathlib. Please check your installation.")
|
@@ -97,6 +96,11 @@ except ImportError as e:
|
|
97
96
|
print(e)
|
98
97
|
raise ImportError("Error importing wolf_texture, xyz_file, mesh2d, PyPalette, wolfresults_2D, PyTranslate, PyVertex, RatingCurve, wolf_array, PyParams, mesh2d.bc_manager, PyVertexvectors, Results2DGPU, PyCrosssections, GraphNotebook, lazviewer, picc, wolf_zi_db, math_parser.calculator, wintab. Please check your installation.")
|
99
98
|
|
99
|
+
try:
|
100
|
+
from .dike import DikeWolf, Wolf_Param_dike
|
101
|
+
except:
|
102
|
+
logging.warning(_("Missing package. Install wolfpydike module via pip."))
|
103
|
+
|
100
104
|
try:
|
101
105
|
from .hydrometry.kiwis_wolfgui import hydrometry_wolfgui
|
102
106
|
except ImportError as e:
|
@@ -125,6 +129,12 @@ except ImportError as e:
|
|
125
129
|
print(e)
|
126
130
|
raise ImportError("Error importing apps.curvedigitizer. Please check your installation.")
|
127
131
|
|
132
|
+
try:
|
133
|
+
from .drowning_victims.drowning_class import Drowning_victim_Viewer
|
134
|
+
except ImportError as e:
|
135
|
+
print(e)
|
136
|
+
raise ImportError("Error importing Drowning_victims.Class. Please check your installation.")
|
137
|
+
|
128
138
|
ID_SELECTCS = 1000
|
129
139
|
ID_SORTALONG = 1001
|
130
140
|
ID_LOCMINMAX = 1002
|
@@ -603,6 +613,8 @@ class draw_type(Enum):
|
|
603
613
|
TILES = 'tiles'
|
604
614
|
IMAGESTILES = 'imagestiles'
|
605
615
|
LAZ = 'laz'
|
616
|
+
DROWNING = 'drowning'
|
617
|
+
DIKE = 'dike'
|
606
618
|
|
607
619
|
class Colors_1to9(wx.Frame):
|
608
620
|
|
@@ -1197,6 +1209,273 @@ class Sim_Explorer(wx.Frame):
|
|
1197
1209
|
self._step_num.Set([str(i) for i in self._all_times_steps[1]])
|
1198
1210
|
|
1199
1211
|
|
1212
|
+
class Drowning_Explorer(wx.Frame):
|
1213
|
+
|
1214
|
+
def __init__(self, parent, title, mapviewer:any, sim:Drowning_victim_Viewer):
|
1215
|
+
|
1216
|
+
super().__init__(parent, title=title, size=(150, 250), style = wx.DEFAULT_FRAME_STYLE & ~ (wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX))
|
1217
|
+
|
1218
|
+
self._panel = wx.Panel(self)
|
1219
|
+
|
1220
|
+
self.mapviewer = mapviewer
|
1221
|
+
self.active_drowning:Drowning_victim_Viewer = sim
|
1222
|
+
|
1223
|
+
main_sizer = wx.BoxSizer(wx.HORIZONTAL)
|
1224
|
+
|
1225
|
+
left_bar = wx.BoxSizer(wx.VERTICAL)
|
1226
|
+
right_bar = wx.BoxSizer(wx.VERTICAL)
|
1227
|
+
|
1228
|
+
self._all_times_steps = self.active_drowning.wanted_time
|
1229
|
+
|
1230
|
+
# Right bar
|
1231
|
+
# ---------
|
1232
|
+
|
1233
|
+
# Slider
|
1234
|
+
self._slider_steps = wx.Slider(self._panel, minValue=1, maxValue=len(self.active_drowning.wanted_time)-1, style=wx.SL_HORIZONTAL | wx.SL_AUTOTICKS | wx.SL_MIN_MAX_LABELS | wx.SL_LABELS)
|
1235
|
+
self._slider_steps.Bind(wx.EVT_SLIDER, self.OnSliderSteps)
|
1236
|
+
right_bar.Add(self._slider_steps, 1, wx.EXPAND | wx.ALL, 2)
|
1237
|
+
|
1238
|
+
self._time_drowning = wx.TextCtrl(self._panel, value=f"Drowning at 0 days, 0 hours,\n0 minutes and 0 seconds", style=wx.TE_MULTILINE | wx.TE_READONLY | wx.TE_CENTER)
|
1239
|
+
right_bar.Add(self._time_drowning, 0, wx.EXPAND | wx.ALL, 2)
|
1240
|
+
|
1241
|
+
# Explore by time
|
1242
|
+
self._label_time = wx.StaticText(self._panel, label=_('Time [s]'))
|
1243
|
+
right_bar.Add(self._label_time, 1, wx.EXPAND | wx.ALL, 2)
|
1244
|
+
|
1245
|
+
_now = datetime.now()
|
1246
|
+
self._starting_date = datetime(year=_now.year, month=_now.month, day=_now.day, hour=0, minute=0, second=0)
|
1247
|
+
self._texttime = wx.TextCtrl(self._panel, value=self._starting_date.strftime('%Y-%m-%d %H:%M:%S'))
|
1248
|
+
right_bar.Add(self._texttime, 1, wx.EXPAND | wx.ALL, 5)
|
1249
|
+
self._texttime.Bind(wx.EVT_TEXT, self.OnTextTime)
|
1250
|
+
|
1251
|
+
self._step_time = wx.ListBox(self._panel, choices=['{:.3f} - {}'.format(i, datetime.strftime(self._starting_date + timedelta(seconds=i), '%Y-%m-%d %H:%M:%S')) for i in self._all_times_steps[:-1]], style=wx.LB_SINGLE)
|
1252
|
+
self._step_time.Bind(wx.EVT_LISTBOX, self.OnSelectNumStep)
|
1253
|
+
right_bar.Add(self._step_time, 1, wx.EXPAND | wx.ALL, 5)
|
1254
|
+
|
1255
|
+
self._step_idx = wx.ListBox(self._panel, choices=[str(i) for i in range(1, len(self.active_drowning.wanted_time)-1+1)], style=wx.LB_SINGLE)
|
1256
|
+
self._step_idx.Bind(wx.EVT_LISTBOX, self.OnSelectIdxStep)
|
1257
|
+
right_bar.Add(self._step_idx, 1, wx.EXPAND | wx.ALL, 5)
|
1258
|
+
|
1259
|
+
# Left bar
|
1260
|
+
# --------
|
1261
|
+
|
1262
|
+
# Apply selected step
|
1263
|
+
self._cmd_apply = wx.Button(self._panel, wx.ID_APPLY, _('Apply'))
|
1264
|
+
self._cmd_apply.SetToolTip(_('Apply the selected parameters to the map'))
|
1265
|
+
self._cmd_apply.Bind(wx.EVT_BUTTON, self.OnApply)
|
1266
|
+
left_bar.Add(self._cmd_apply, 1, wx.EXPAND | wx.ALL, 5)
|
1267
|
+
|
1268
|
+
# Next step
|
1269
|
+
self._cmd_next = wx.Button(self._panel, wx.ID_FORWARD, _('Next'))
|
1270
|
+
self._cmd_next.SetToolTip(_('Go to the next step -- using the selected mode'))
|
1271
|
+
self._cmd_next.Bind(wx.EVT_BUTTON, self.OnNext)
|
1272
|
+
left_bar.Add(self._cmd_next, 1, wx.EXPAND | wx.ALL, 5)
|
1273
|
+
|
1274
|
+
# Previous step
|
1275
|
+
self._cmd_prev = wx.Button(self._panel, wx.ID_BACKWARD, _('Previous'))
|
1276
|
+
self._cmd_prev.SetToolTip(_('Go to the previous step -- using the selected mode'))
|
1277
|
+
self._cmd_prev.Bind(wx.EVT_BUTTON, self.OnPrev)
|
1278
|
+
left_bar.Add(self._cmd_prev, 1, wx.EXPAND | wx.ALL, 5)
|
1279
|
+
|
1280
|
+
self.Bind(wx.EVT_CLOSE, self.OnClose)
|
1281
|
+
|
1282
|
+
main_sizer.Add(left_bar, 1, wx.EXPAND | wx.ALL, 2)
|
1283
|
+
main_sizer.Add(right_bar, 1, wx.EXPAND | wx.ALL, 2)
|
1284
|
+
|
1285
|
+
self._panel.SetSizer(main_sizer)
|
1286
|
+
self._panel.SetAutoLayout(True)
|
1287
|
+
|
1288
|
+
self.MinSize = (450, 500)
|
1289
|
+
|
1290
|
+
self.Fit()
|
1291
|
+
self.Show()
|
1292
|
+
|
1293
|
+
self.SetIcon(wx.Icon(str(Path(__file__).parent / "apps/wolf_logo2.bmp")))
|
1294
|
+
|
1295
|
+
self._set_all(0)
|
1296
|
+
|
1297
|
+
def _find_next(self, idx:int):
|
1298
|
+
""" Find the next step based on the mode and interval """
|
1299
|
+
|
1300
|
+
mode = 2
|
1301
|
+
if mode == 0:
|
1302
|
+
# By time [s]
|
1303
|
+
next_time = self._all_times_steps[idx] + float(self._interval.GetValue())
|
1304
|
+
diff = [abs(next_time - i) for i in self._all_times_steps[idx:]]
|
1305
|
+
next_idx = diff.index(min(diff)) + idx
|
1306
|
+
|
1307
|
+
return next_idx
|
1308
|
+
|
1309
|
+
elif mode == 1:
|
1310
|
+
# By time [hour]
|
1311
|
+
next_time = self._all_times_steps[idx] + float(self._interval.GetValue())*3600
|
1312
|
+
diff = [abs(next_time - i) for i in self._all_times_steps[idx:]]
|
1313
|
+
next_idx = diff.index(min(diff)) + idx
|
1314
|
+
|
1315
|
+
return next_idx
|
1316
|
+
|
1317
|
+
elif mode == 2:
|
1318
|
+
# By index
|
1319
|
+
next_idx = min(idx + int(1), len(self._all_times_steps)-1)
|
1320
|
+
|
1321
|
+
return next_idx
|
1322
|
+
|
1323
|
+
elif mode == 3:
|
1324
|
+
# By time step
|
1325
|
+
next_idx = self._all_times_steps[1].index(self._all_times_steps[idx] + int(1))
|
1326
|
+
diff = [abs(next_idx - i) for i in self._all_times_steps[idx:]]
|
1327
|
+
next_idx = diff.index(min(diff)) + idx
|
1328
|
+
|
1329
|
+
return next_idx
|
1330
|
+
|
1331
|
+
def _find_prev(self, idx:int):
|
1332
|
+
""" Find the previous step based on the mode and interval """
|
1333
|
+
|
1334
|
+
mode = 2
|
1335
|
+
|
1336
|
+
if mode == 0:
|
1337
|
+
# By time [s]
|
1338
|
+
prev_time = self._all_times_steps[idx] - float(1)
|
1339
|
+
diff = [abs(prev_time - i) for i in self._all_times_steps[:idx]]
|
1340
|
+
prev_idx = diff.index(min(diff))
|
1341
|
+
|
1342
|
+
return prev_idx
|
1343
|
+
|
1344
|
+
elif mode == 1:
|
1345
|
+
# By time [hour]
|
1346
|
+
prev_time = self._all_times_steps[idx] - float(1)*3600
|
1347
|
+
diff = [abs(prev_time - i) for i in self._all_times_steps[:idx]]
|
1348
|
+
prev_idx = diff.index(min(diff))
|
1349
|
+
|
1350
|
+
return prev_idx
|
1351
|
+
|
1352
|
+
elif mode == 2:
|
1353
|
+
# By index
|
1354
|
+
prev_idx = max(idx - int(1), 0)
|
1355
|
+
|
1356
|
+
return prev_idx
|
1357
|
+
|
1358
|
+
elif mode == 3:
|
1359
|
+
# By time step
|
1360
|
+
prev_idx = self._all_times_steps[1].index(self._all_times_steps[idx] - int(1))
|
1361
|
+
diff = [abs(prev_idx - i) for i in self._all_times_steps[:idx]]
|
1362
|
+
prev_idx = diff.index(min(diff))
|
1363
|
+
|
1364
|
+
return prev_idx
|
1365
|
+
|
1366
|
+
def OnNext(self, event):
|
1367
|
+
""" Go to the next step """
|
1368
|
+
|
1369
|
+
selected_step = self._slider_steps.GetValue()+1
|
1370
|
+
next_idx = self._find_next(selected_step)
|
1371
|
+
|
1372
|
+
if next_idx != selected_step:
|
1373
|
+
self._set_all(next_idx)
|
1374
|
+
self.Refresh(next_idx)
|
1375
|
+
|
1376
|
+
def OnTextTime(self, event):
|
1377
|
+
try:
|
1378
|
+
self._starting_date = datetime.strptime(self._texttime.GetValue(), '%Y-%m-%d %H:%M:%S')
|
1379
|
+
self._step_time.Set(['{:.3f} - {}'.format(int(i/3600/24), datetime.strftime(self._starting_date + timedelta(seconds=i), '%Y-%m-%d %H:%M:%S')) for i in self._all_times_steps[:-1]])
|
1380
|
+
except:
|
1381
|
+
pass
|
1382
|
+
|
1383
|
+
def OnPrev(self, event):
|
1384
|
+
""" Go to the previous step """
|
1385
|
+
|
1386
|
+
selected_step = self._slider_steps.GetValue()-1
|
1387
|
+
prev_idx = self._find_prev(selected_step)
|
1388
|
+
|
1389
|
+
if prev_idx != selected_step:
|
1390
|
+
self._set_all(prev_idx)
|
1391
|
+
self.Refresh(prev_idx)
|
1392
|
+
|
1393
|
+
def OnClose(self, event):
|
1394
|
+
""" Close the simulation explorer """
|
1395
|
+
|
1396
|
+
self.mapviewer._pop_sim_explorer(self.active_drowning)
|
1397
|
+
self.Destroy()
|
1398
|
+
|
1399
|
+
def OnUpdate(self, event):
|
1400
|
+
self._update()
|
1401
|
+
|
1402
|
+
def OnApply(self, event):
|
1403
|
+
selected_step = self._slider_steps.GetValue()-1
|
1404
|
+
|
1405
|
+
self._cmd_apply.SetBackgroundColour(wx.Colour(255, 0, 0)) # Set button color to red
|
1406
|
+
self._cmd_apply.Refresh() # Refresh the button to apply the color change
|
1407
|
+
|
1408
|
+
self.Refresh(selected_step)
|
1409
|
+
|
1410
|
+
self._cmd_apply.SetBackgroundColour(wx.NullColour) # Reset button color to default
|
1411
|
+
self._cmd_apply.Refresh() # Refresh the button to apply the color change
|
1412
|
+
|
1413
|
+
def _set_all(self, idx:int):
|
1414
|
+
self._slider_steps.SetValue(idx+1)
|
1415
|
+
self._step_idx.SetSelection(idx)
|
1416
|
+
|
1417
|
+
def Refresh(self, idx:int):
|
1418
|
+
self.active_drowning.read_oneresult(idx)
|
1419
|
+
self.mapviewer.Refresh()
|
1420
|
+
|
1421
|
+
def OnSliderSteps(self, event):
|
1422
|
+
selected_step = self._slider_steps.GetValue()-1
|
1423
|
+
self.active_drowning.time_id = selected_step
|
1424
|
+
time_id = self._slider_steps.GetValue()-1
|
1425
|
+
time_value = self.active_drowning.wanted_time[time_id]
|
1426
|
+
|
1427
|
+
days = np.floor(time_value // 86400)
|
1428
|
+
hours = np.floor((time_value % 86400) / 3600)
|
1429
|
+
minutes = np.floor(((time_value % 86400) % 3600) / 60)
|
1430
|
+
seconds = np.floor(((time_value % 86400) % 3600) % 60)
|
1431
|
+
|
1432
|
+
self._time_drowning.SetValue(
|
1433
|
+
f"Drowning at {int(days)} days, {int(hours)} hours,\n"
|
1434
|
+
f"{int(minutes)} minutes and {int(seconds)} seconds"
|
1435
|
+
)
|
1436
|
+
self._set_all(selected_step)
|
1437
|
+
|
1438
|
+
def OnSelectNumStep(self, event):
|
1439
|
+
selected_step = self._step_time.GetSelection()
|
1440
|
+
self.active_drowning.time_id = selected_step
|
1441
|
+
time_id = selected_step
|
1442
|
+
time_value = self.active_drowning.wanted_time[time_id]
|
1443
|
+
|
1444
|
+
days = np.floor(time_value // 86400)
|
1445
|
+
hours = np.floor((time_value % 86400) / 3600)
|
1446
|
+
minutes = np.floor(((time_value % 86400) % 3600) / 60)
|
1447
|
+
seconds = np.floor(((time_value % 86400) % 3600) % 60)
|
1448
|
+
|
1449
|
+
self._time_drowning.SetValue(
|
1450
|
+
f"Drowning at {int(days)} days, {int(hours)} hours,\n"
|
1451
|
+
f"{int(minutes)} minutes and {int(seconds)} seconds"
|
1452
|
+
)
|
1453
|
+
self._set_all(selected_step)
|
1454
|
+
|
1455
|
+
def OnSelectIdxStep(self, event):
|
1456
|
+
selected_step = self._step_idx.GetSelection()
|
1457
|
+
self.active_drowning.time_id = selected_step
|
1458
|
+
time_id = selected_step
|
1459
|
+
time_value = self.active_drowning.wanted_time[time_id]
|
1460
|
+
|
1461
|
+
days = np.floor(time_value // 86400)
|
1462
|
+
hours = np.floor((time_value % 86400) / 3600)
|
1463
|
+
minutes = np.floor(((time_value % 86400) % 3600) / 60)
|
1464
|
+
seconds = np.floor(((time_value % 86400) % 3600) % 60)
|
1465
|
+
|
1466
|
+
self._time_drowning.SetValue(
|
1467
|
+
f"Drowning at {int(days)} days, {int(hours)} hours,\n"
|
1468
|
+
f"{int(minutes)} minutes and {int(seconds)} seconds"
|
1469
|
+
)
|
1470
|
+
self._set_all(selected_step)
|
1471
|
+
|
1472
|
+
def _update(self):
|
1473
|
+
nb = len(self.active_drowning.wanted_time)
|
1474
|
+
self._all_times_steps = self.active_drowning.wanted_time
|
1475
|
+
|
1476
|
+
self._slider_steps.SetMax(nb)
|
1477
|
+
self._step_idx.Set([str(i) for i in range(1,nb+1)])
|
1478
|
+
|
1200
1479
|
class Select_Begin_end_interval_step(wx.Dialog):
|
1201
1480
|
""" wx.frame to select the begin and end of the interval to extract """
|
1202
1481
|
|
@@ -1636,6 +1915,8 @@ class WolfMapViewer(wx.Frame):
|
|
1636
1915
|
mypartsystems: list[Particle_system]
|
1637
1916
|
myviewers3d:list[Wolf_Viewer3D]
|
1638
1917
|
mylazdata:list[Wolf_LAZ_Data]
|
1918
|
+
mydrownings: list[Drowning_victim_Viewer]
|
1919
|
+
mydikes: list[DikeWolf]
|
1639
1920
|
|
1640
1921
|
mymplfigs:list[MplFigViewer]
|
1641
1922
|
|
@@ -1670,9 +1951,32 @@ class WolfMapViewer(wx.Frame):
|
|
1670
1951
|
active_weirs : Weirs
|
1671
1952
|
active_weir : Weir
|
1672
1953
|
active_laz : Wolf_LAZ_Data
|
1954
|
+
active_drowning: Drowning_victim_Viewer
|
1955
|
+
active_dike : DikeWolf
|
1673
1956
|
|
1674
1957
|
active_fig: MplFigViewer
|
1675
1958
|
|
1959
|
+
|
1960
|
+
# def check_user_activity(self, *args):
|
1961
|
+
# while True:
|
1962
|
+
# sleep(1)
|
1963
|
+
# if datetime.now() - self._last_activity_time > timedelta(seconds=3): # 5 secondes d'inactivité
|
1964
|
+
# args[0]._user_active = False
|
1965
|
+
|
1966
|
+
# def _user_activity_true(self):
|
1967
|
+
# self._user_active = True
|
1968
|
+
# self._last_activity_time = datetime.now()
|
1969
|
+
|
1970
|
+
# def background_task(self, *args):
|
1971
|
+
|
1972
|
+
# while args[0]._user_active:
|
1973
|
+
# sleep(1)
|
1974
|
+
|
1975
|
+
# args[0]._update_background()
|
1976
|
+
# args[0].Paint()
|
1977
|
+
|
1978
|
+
# args[0]._thread_update_background = None
|
1979
|
+
|
1676
1980
|
def __init__(self,
|
1677
1981
|
wxparent = None,
|
1678
1982
|
title:str = _('Default Wolf Map Viewer'),
|
@@ -1695,6 +1999,12 @@ class WolfMapViewer(wx.Frame):
|
|
1695
1999
|
|
1696
2000
|
"""
|
1697
2001
|
|
2002
|
+
# self._user_active = True # True if the user is active in the viewer
|
2003
|
+
# self._last_activity_time = datetime.now() # last time the user was active in the viewer
|
2004
|
+
# self._check_activity_thread = threading.Thread(target=self.check_user_activity, args=[self]) # thread to check user activity
|
2005
|
+
# self._check_activity_thread.start() # start the thread
|
2006
|
+
# self._thread_update_background = None # thread to update the background
|
2007
|
+
|
1698
2008
|
self.treewidth = treewidth
|
1699
2009
|
super(WolfMapViewer, self).__init__(wxparent, title=title, size=(w + self.treewidth, h))
|
1700
2010
|
|
@@ -1758,7 +2068,7 @@ class WolfMapViewer(wx.Frame):
|
|
1758
2068
|
self.popupmenu = wx.Menu()
|
1759
2069
|
self.popupmenu.Bind(wx.EVT_MENU, self.OnPopupItemSelected)
|
1760
2070
|
|
1761
|
-
for text in [_('Save'), _('Save as'), _('Rename'), _('Duplicate'), _('Delete'), _('Up'), _('Down'), _('Properties')]:
|
2071
|
+
for text in [_('Save'), _('Save as'), _('Rename'), _('Duplicate'), _('Delete'), _('Up'), _('Down'), _('Check/Uncheck'), _('Properties')]:
|
1762
2072
|
item = self.popupmenu.Append(-1, text)
|
1763
2073
|
|
1764
2074
|
self.menubar = wx.MenuBar()
|
@@ -1777,6 +2087,8 @@ class WolfMapViewer(wx.Frame):
|
|
1777
2087
|
self.menulaz = None
|
1778
2088
|
self.menutiles = None
|
1779
2089
|
self.menuimagestiles = None
|
2090
|
+
self.menudrowning = None
|
2091
|
+
self.menudike = None
|
1780
2092
|
|
1781
2093
|
self.filemenu = wx.Menu()
|
1782
2094
|
openitem = self.filemenu.Append(wx.ID_OPEN, _('Open/Add project'), _('Open a full project from file'))
|
@@ -1854,6 +2166,8 @@ class WolfMapViewer(wx.Frame):
|
|
1854
2166
|
createbcmanager2D = self.menucreateobj.Append(wx.ID_ANY, _('Create BC manager Wolf2D...'), _('New BC manager 2D'))
|
1855
2167
|
createpartsystem = self.menucreateobj.Append(wx.ID_ANY, _('Create particle system...'), _('Create a particle system - Lagrangian view'))
|
1856
2168
|
create_acceptability = self.menucreateobj.Append(wx.ID_ANY, _('Create acceptability manager...'), _('Create acceptability manager'))
|
2169
|
+
createdrowning = self.menucreateobj.Append(wx.ID_ANY, _('Create a drowning...'),_('Create a drowning'))
|
2170
|
+
createdike = self.menucreateobj.Append(wx.ID_ANY, _('Create dike...'), _('New dike'))
|
1857
2171
|
|
1858
2172
|
self.filemenu.AppendSeparator()
|
1859
2173
|
|
@@ -1879,6 +2193,8 @@ class WolfMapViewer(wx.Frame):
|
|
1879
2193
|
addbridges = self.menuaddobj.Append(wx.ID_ANY, _('Add bridges...'), _('Add bridges from directory'))
|
1880
2194
|
addweirs = self.menuaddobj.Append(wx.ID_ANY, _('Add weirs...'), _('Add bridges from directory'))
|
1881
2195
|
addview = self.menuaddobj.Append(wx.ID_ANY, _('Add view...'), _('Add view from project file'))
|
2196
|
+
adddrowning = self.menuaddobj.Append(wx.ID_ANY, _('Add a drowning result...'),_('Add a drowning result'))
|
2197
|
+
adddike = self.menuaddobj.Append(wx.ID_ANY, _('Add dike...'), _('Add dike'))
|
1882
2198
|
|
1883
2199
|
self.precomputed_menu = None
|
1884
2200
|
if self.default_dem != "":
|
@@ -2047,8 +2363,10 @@ class WolfMapViewer(wx.Frame):
|
|
2047
2363
|
self.active_weirs = None
|
2048
2364
|
self.active_weir = None
|
2049
2365
|
self.active_laz = None
|
2366
|
+
self.active_dike = None
|
2050
2367
|
|
2051
2368
|
self.active_fig = None
|
2369
|
+
self.active_drowning = None
|
2052
2370
|
|
2053
2371
|
curtool = self.tools[ID_SORTALONG] = {}
|
2054
2372
|
curtool['menu'] = self.sortalong
|
@@ -2108,6 +2426,8 @@ class WolfMapViewer(wx.Frame):
|
|
2108
2426
|
self.myitemsviews = self.treelist.AppendItem(self.root, _("Views"))
|
2109
2427
|
self.myitemswmsback = self.treelist.AppendItem(self.root, _("WMS-background"))
|
2110
2428
|
self.myitemswmsfore = self.treelist.AppendItem(self.root, _("WMS-foreground"))
|
2429
|
+
self.myitemsdrowning = self.treelist.AppendItem(self.root,_("Drowning"))
|
2430
|
+
self.myitemsdike = self.treelist.AppendItem(self.root, _("Dikes"))
|
2111
2431
|
|
2112
2432
|
width, height = self.GetClientSize()
|
2113
2433
|
self.bordersize = int((w - width + self.treewidth) / 2)
|
@@ -2584,6 +2904,62 @@ class WolfMapViewer(wx.Frame):
|
|
2584
2904
|
|
2585
2905
|
self.menuwalous.Bind(wx.EVT_MENU, self.Onmenuwalous)
|
2586
2906
|
|
2907
|
+
def menu_drowning(self):
|
2908
|
+
|
2909
|
+
if self.menudrowning is None:
|
2910
|
+
|
2911
|
+
self.menudrowning = wx.Menu()
|
2912
|
+
|
2913
|
+
self.menudrowning_plot = wx.Menu()
|
2914
|
+
|
2915
|
+
self.menudrowning_explore_results = self.menudrowning.Append(wx.ID_ANY, _("Explore time/index results"), _("Open a dialog to explore time/index results"))
|
2916
|
+
|
2917
|
+
self.menudrowning.AppendSeparator()
|
2918
|
+
|
2919
|
+
self.menudrowning.Append(wx.ID_ANY, _("Plot..."),self.menudrowning_plot)
|
2920
|
+
self.plot_runs = self.menudrowning_plot.Append(wx.ID_ANY, _("Plot runs positions"), _("Plot runs positions"),kind=wx.ITEM_CHECK)
|
2921
|
+
self.plot_cells = self.menudrowning_plot.Append(wx.ID_ANY, _("Plot cells positions"), _("Plot the cells where bodies colored as a function of bodies in it"),kind=wx.ITEM_CHECK)
|
2922
|
+
self.plot_KDE = self.menudrowning_plot.Append(wx.ID_ANY, _("Plot KDE"), _("Plot Kernel Density Estimation - Map of probability of presence"),kind=wx.ITEM_CHECK)
|
2923
|
+
|
2924
|
+
self.menudrowning_lastres = self.menudrowning.Append(wx.ID_ANY, _("Read last result"), _("Current view"))
|
2925
|
+
|
2926
|
+
self.menudrowning_zoom = self.menudrowning.Append(wx.ID_ANY, _("Zoom on hotspots"), _("Zoom on areas where you have the highest probability of presence"))
|
2927
|
+
|
2928
|
+
self.menudrowning.AppendSeparator()
|
2929
|
+
|
2930
|
+
self.menudrowning_get_bodies = self.menudrowning.Append(wx.ID_ANY, _("Get bodies characteristics"), _("Get a table of the characteristics of all simulated bodies"))
|
2931
|
+
self.menudrowning_get_perc = self.menudrowning.Append(wx.ID_ANY, _("Vertical position proportion"), _("Get proportion of runs at the surface and at the bottom at selected time"))
|
2932
|
+
|
2933
|
+
self.menudrowning.AppendSeparator()
|
2934
|
+
|
2935
|
+
self.menudrowning_video = self.menudrowning.Append(wx.ID_ANY, _("Create video..."), _("Video/Movie"))
|
2936
|
+
|
2937
|
+
self.menubar.Append(self.menudrowning, _('Drowning'))
|
2938
|
+
|
2939
|
+
self.menudrowning.Bind(wx.EVT_MENU, self.Onmenudrowning)
|
2940
|
+
|
2941
|
+
def menu_dike(self):
|
2942
|
+
|
2943
|
+
if self.menudike is None:
|
2944
|
+
self.menudike = wx.Menu()
|
2945
|
+
|
2946
|
+
self.menudike_launchsimu = self.menudike.Append(wx.ID_ANY, _("Launch simulation"), _("Launch simulation"))
|
2947
|
+
|
2948
|
+
self.menudike.AppendSeparator()
|
2949
|
+
|
2950
|
+
self.menudike_showtri = self.menudike.Append(wx.ID_ANY, _("Show triangulation"), _("Show triangulation"))
|
2951
|
+
self.menudike_plotQ = self.menudike.Append(wx.ID_ANY, _("Plot discharges"), _("Plot discharges"))
|
2952
|
+
self.menudike_plotz = self.menudike.Append(wx.ID_ANY, _("Plot water levels/breach bottom"), _("Plot water levels/breach bottom"))
|
2953
|
+
self.menudike_plotB = self.menudike.Append(wx.ID_ANY, _("Plot breach width"), _("Plot breach width"))
|
2954
|
+
|
2955
|
+
self.menudike.AppendSeparator()
|
2956
|
+
|
2957
|
+
self.menudike_showparam = self.menudike.Append(wx.ID_ANY, _("Show parameters"), _("Show parameters"))
|
2958
|
+
|
2959
|
+
self.menubar.Append(self.menudike, _('Dike'))
|
2960
|
+
|
2961
|
+
self.menudike.Bind(wx.EVT_MENU, self.Onmenudike)
|
2962
|
+
|
2587
2963
|
|
2588
2964
|
def get_canvas_bounds(self, gridsize:float = None):
|
2589
2965
|
"""
|
@@ -2786,6 +3162,115 @@ class WolfMapViewer(wx.Frame):
|
|
2786
3162
|
if which in self.sim_explorers:
|
2787
3163
|
self.sim_explorers[which]._set_all(which.current_result)
|
2788
3164
|
|
3165
|
+
def Onmenudrowning(self, event: wx.MenuEvent):
|
3166
|
+
|
3167
|
+
id = event.GetId()
|
3168
|
+
item = self.menubar.FindItemById(event.GetId())
|
3169
|
+
|
3170
|
+
if item is None:
|
3171
|
+
return
|
3172
|
+
|
3173
|
+
itemlabel = item.ItemLabel
|
3174
|
+
|
3175
|
+
|
3176
|
+
if itemlabel == _("Read last result"):
|
3177
|
+
|
3178
|
+
self.active_drowning.read_last_result()
|
3179
|
+
self.Refresh()
|
3180
|
+
self._update_mytooltip()
|
3181
|
+
|
3182
|
+
elif itemlabel == _("Explore time/index results"):
|
3183
|
+
if self.active_drowning is None:
|
3184
|
+
logging.warning(_('No active drowning ! -- Please activate a drowning first'))
|
3185
|
+
return
|
3186
|
+
which = self.active_drowning
|
3187
|
+
self.sim_explorers[which] = Drowning_Explorer(self,title=f'Explore drowning results: {self.active_drowning.idx}',mapviewer=self, sim=which)
|
3188
|
+
|
3189
|
+
elif itemlabel == _("Plot runs positions"):
|
3190
|
+
if self.plot_runs.IsChecked():
|
3191
|
+
self.active_drowning.prepare_plot_runs_positions()
|
3192
|
+
else:
|
3193
|
+
self.active_drowning.reset_plot_runs_positions()
|
3194
|
+
self._update_mytooltip()
|
3195
|
+
self.Refresh()
|
3196
|
+
|
3197
|
+
|
3198
|
+
elif itemlabel == _("Plot cells positions"):
|
3199
|
+
if self.plot_cells.IsChecked():
|
3200
|
+
self._update_mytooltip()
|
3201
|
+
self.active_drowning.prepare_plot_cells_positions()
|
3202
|
+
else:
|
3203
|
+
self.active_drowning.reset_plot_cells_positions()
|
3204
|
+
self._update_mytooltip()
|
3205
|
+
self.Refresh()
|
3206
|
+
|
3207
|
+
elif itemlabel == _("Plot KDE"):
|
3208
|
+
if self.plot_KDE.IsChecked():
|
3209
|
+
self.active_drowning.prepare_plot_kde()
|
3210
|
+
else:
|
3211
|
+
self.active_drowning.reset_plot_kde()
|
3212
|
+
self._update_mytooltip()
|
3213
|
+
self.Refresh()
|
3214
|
+
|
3215
|
+
elif itemlabel == _("Zoom on hotspots"):
|
3216
|
+
self.memory_views = Memory_Views()
|
3217
|
+
self.active_drowning.zoom_on_hotspots(self.memory_views)
|
3218
|
+
self._memory_views_gui = Memory_Views_GUI(self, _('Memory view manager'), self.memory_views, mapviewer = self)
|
3219
|
+
|
3220
|
+
elif itemlabel == _("Get bodies characteristics"):
|
3221
|
+
self.active_drowning.get_bodies_characteristics()
|
3222
|
+
|
3223
|
+
elif itemlabel == _("Vertical position proportion"):
|
3224
|
+
self.active_drowning.get_vertical_position_proportion()
|
3225
|
+
|
3226
|
+
elif itemlabel == _("Create video..."):
|
3227
|
+
logging.info(_("Not yet implemeted"))
|
3228
|
+
return
|
3229
|
+
|
3230
|
+
|
3231
|
+
def Onmenudike(self, event: wx.MenuEvent):
|
3232
|
+
|
3233
|
+
id = event.GetId()
|
3234
|
+
item = self.menubar.FindItemById(event.GetId())
|
3235
|
+
|
3236
|
+
if item is None:
|
3237
|
+
return
|
3238
|
+
|
3239
|
+
itemlabel = item.ItemLabel
|
3240
|
+
|
3241
|
+
if self.active_dike is None:
|
3242
|
+
logging.warning(_('No active dike -- Please activate a dike first'))
|
3243
|
+
return
|
3244
|
+
|
3245
|
+
class plot_types(Enum):
|
3246
|
+
"""
|
3247
|
+
Enum class for plot types.
|
3248
|
+
"""
|
3249
|
+
DISCHARGES = 0
|
3250
|
+
LEVELS = 1
|
3251
|
+
BREACHWIDTH = 2
|
3252
|
+
|
3253
|
+
if itemlabel == _("Launch simulation"):
|
3254
|
+
|
3255
|
+
self.active_dike.run()
|
3256
|
+
|
3257
|
+
elif itemlabel == _("Show triangulation"):
|
3258
|
+
|
3259
|
+
self.active_dike.show_triangulation()
|
3260
|
+
|
3261
|
+
elif itemlabel == _("Plot discharges"):
|
3262
|
+
self.active_dike.plot_mainOutputs(plot_types.DISCHARGES.value)
|
3263
|
+
|
3264
|
+
elif itemlabel == _("Plot water levels/breach bottom"):
|
3265
|
+
self.active_dike.plot_mainOutputs(plot_types.LEVELS.value)
|
3266
|
+
|
3267
|
+
elif itemlabel == _("Plot breach width"):
|
3268
|
+
self.active_dike.plot_mainOutputs(plot_types.BREACHWIDTH.value)
|
3269
|
+
|
3270
|
+
elif itemlabel == _("Show parameters"):
|
3271
|
+
self.active_dike.show_properties()
|
3272
|
+
|
3273
|
+
|
2789
3274
|
def Onmenuwolf2d(self, event: wx.MenuEvent):
|
2790
3275
|
|
2791
3276
|
id = event.GetId()
|
@@ -4519,6 +5004,7 @@ class WolfMapViewer(wx.Frame):
|
|
4519
5004
|
self.canvas.Bind(wx.EVT_RIGHT_DCLICK, self.On_Right_Double_Clicks)
|
4520
5005
|
self.canvas.Bind(wx.EVT_LEFT_DCLICK, self.On_Left_Double_Clicks)
|
4521
5006
|
self.canvas.Bind(wx.EVT_LEFT_DOWN, self.On_Mouse_Left_Down)
|
5007
|
+
self.canvas.Bind(wx.EVT_LEFT_UP, self.On_Mouse_Left_Up)
|
4522
5008
|
self.canvas.Bind(wx.EVT_MIDDLE_DOWN, self.On_Mouse_Left_Down)
|
4523
5009
|
self.canvas.Bind(wx.EVT_RIGHT_DOWN, self.On_Mouse_Right_Down)
|
4524
5010
|
self.canvas.Bind(wx.EVT_RIGHT_UP, self.On_Mouse_Right_Up)
|
@@ -4551,13 +5037,15 @@ class WolfMapViewer(wx.Frame):
|
|
4551
5037
|
self.myviewers3d = []
|
4552
5038
|
self.myviewerslaz = []
|
4553
5039
|
self.mylazdata = []
|
5040
|
+
self.mydrownings = []
|
5041
|
+
self.mydikes = []
|
4554
5042
|
|
4555
5043
|
self.mymplfigs = []
|
4556
5044
|
|
4557
5045
|
self.sim_explorers = {}
|
4558
5046
|
|
4559
5047
|
# liste des éléments modifiable dans l'arbre
|
4560
|
-
self.all_lists = [self.myarrays, self.myvectors, self.myclouds, self.mytri, self.myothers, self.myviews, self.myres2D, self.mytiles, self.myimagestiles, self.mypartsystems, self.myviewers3d, self.myviewerslaz]
|
5048
|
+
self.all_lists = [self.myarrays, self.myvectors, self.myclouds, self.mytri, self.myothers, self.myviews, self.myres2D, self.mytiles, self.myimagestiles, self.mypartsystems, self.myviewers3d, self.myviewerslaz, self.mydikes, self.mydrownings]
|
4561
5049
|
|
4562
5050
|
self.menu_options = wx.Menu()
|
4563
5051
|
self._change_title = self.menu_options.Append(wx.ID_ANY, _('Change title'), _('Change title of the window'))
|
@@ -4787,6 +5275,16 @@ class WolfMapViewer(wx.Frame):
|
|
4787
5275
|
'Emprise': 'ZONES_INONDEES',
|
4788
5276
|
'Emprise wo Alea': 'ZONES_INONDEES_wo_alea'}}
|
4789
5277
|
|
5278
|
+
lifewatch = {'LW_ecotopes_lc_hr_raster': {'2006': '2006',
|
5279
|
+
'2010': '2010',
|
5280
|
+
'2015': '2015',
|
5281
|
+
'2018': '2018',
|
5282
|
+
'2019': '2019',
|
5283
|
+
'2020': '2020',
|
5284
|
+
'2021': '2021',
|
5285
|
+
'2022': '2022',
|
5286
|
+
}}
|
5287
|
+
|
4790
5288
|
for idx, (k, item) in enumerate(orthos.items()):
|
4791
5289
|
for kdx, (m, subitem) in enumerate(item.items()):
|
4792
5290
|
self.add_object(which='wmsback',
|
@@ -4801,11 +5299,19 @@ class WolfMapViewer(wx.Frame):
|
|
4801
5299
|
self, xmin, xmax, ymin, ymax, -99999, 1024),
|
4802
5300
|
ToCheck=False, id='Data 2021 ' + m)
|
4803
5301
|
|
5302
|
+
for idx, (k, item) in enumerate(lifewatch.items()):
|
5303
|
+
for kdx, (m, subitem) in enumerate(item.items()):
|
5304
|
+
self.add_object(which='wmsback',
|
5305
|
+
newobj=imagetexture('LanCover', m, k, subitem,
|
5306
|
+
self, xmin, xmax, ymin, ymax, -99999, 1024, LifeWatch=True),
|
5307
|
+
ToCheck=False, id='LifeWatch LC' + m)
|
5308
|
+
|
4804
5309
|
self.add_object(which='wmsback',
|
4805
5310
|
newobj=imagetexture('PPNC', 'Orthos France', 'OI.OrthoimageCoverage.HR', '',
|
4806
5311
|
self, xmin, xmax, ymin, ymax, -99999, 1024, France=True, epsg='EPSG:27563'),
|
4807
5312
|
ToCheck=False, id='Orthos France')
|
4808
5313
|
|
5314
|
+
|
4809
5315
|
forelist = {'EAU': {'Aqualim': 'RES_LIMNI_DGARNE', 'Alea': 'ALEA_INOND', 'Lidaxes': 'LIDAXES'},
|
4810
5316
|
'LIMITES': {'Secteurs Statistiques': 'LIMITES_QS_STATBEL',
|
4811
5317
|
'Limites administratives': 'LIMITES_ADMINISTRATIVES'},
|
@@ -5379,9 +5885,6 @@ class WolfMapViewer(wx.Frame):
|
|
5379
5885
|
def zoom_on_array(self, array:WolfArray, forceupdate=True, canvas_height=1024):
|
5380
5886
|
""" Zoom on array """
|
5381
5887
|
|
5382
|
-
if array.xmin == -99999:
|
5383
|
-
array.find_minmax()
|
5384
|
-
|
5385
5888
|
bounds = array.get_bounds()
|
5386
5889
|
|
5387
5890
|
center = [(bounds[0][1] + bounds[0][0]) / 2., (bounds[1][1] + bounds[1][0]) / 2.]
|
@@ -6932,6 +7435,44 @@ class WolfMapViewer(wx.Frame):
|
|
6932
7435
|
|
6933
7436
|
return ass_values[idx]
|
6934
7437
|
|
7438
|
+
def newdrowning(self,itemlabel):
|
7439
|
+
|
7440
|
+
if itemlabel == ('Create a drowning...'):
|
7441
|
+
new_drowning = Drowning_victim_Viewer(mapviewer = self)
|
7442
|
+
self.add_object(which='drowning',newobj=new_drowning,ToCheck=True)
|
7443
|
+
|
7444
|
+
elif itemlabel == ('Add a drowning result...'):
|
7445
|
+
dialog = wx.DirDialog(None,_("Select the folder containing your drowning"), style=wx.DD_DEFAULT_STYLE)
|
7446
|
+
if dialog.ShowModal() == wx.ID_OK:
|
7447
|
+
# Récupérer le chemin sélectionné
|
7448
|
+
filedir = dialog.GetPath()
|
7449
|
+
dialog.Destroy()
|
7450
|
+
|
7451
|
+
if not os.path.exists(os.path.join(filedir, "Results.npz")):
|
7452
|
+
logging.error(_("The selected folder does not contain any Results.npz"))
|
7453
|
+
return
|
7454
|
+
|
7455
|
+
new_drowning = Drowning_victim_Viewer(mapviewer = self,filedir=filedir)
|
7456
|
+
new_drowning.file_drowning = 1
|
7457
|
+
self.add_object(which='drowning',newobj=new_drowning,ToCheck=True)
|
7458
|
+
new_drowning.load_results()
|
7459
|
+
new_drowning.time_id = len(new_drowning.wanted_time)-2
|
7460
|
+
new_drowning.init_plot()
|
7461
|
+
self.menu_drowning()
|
7462
|
+
|
7463
|
+
def new_dike(self, itemlabel):
|
7464
|
+
"""
|
7465
|
+
Called when 'Create dike...' or 'Add dike...' are selected in the viewer
|
7466
|
+
"""
|
7467
|
+
newdike = DikeWolf(mapviewer = self)
|
7468
|
+
|
7469
|
+
if _('Add dike...') in itemlabel:
|
7470
|
+
newdike.load_results()
|
7471
|
+
|
7472
|
+
self.add_object(which='dike', newobj=newdike, ToCheck = True)#, filename=newdike.filename, id=newdike.filename)
|
7473
|
+
|
7474
|
+
self.menu_dike()
|
7475
|
+
autoscale = True
|
6935
7476
|
|
6936
7477
|
def OnMenubar(self, event: wx.MenuEvent):
|
6937
7478
|
"""
|
@@ -7941,7 +8482,6 @@ class WolfMapViewer(wx.Frame):
|
|
7941
8482
|
if self.mylazgrid is None:
|
7942
8483
|
logging.warning(_('No gridded LAZ data loaded !'))
|
7943
8484
|
return
|
7944
|
-
autoscale=False
|
7945
8485
|
self.clip_laz_gridded()
|
7946
8486
|
|
7947
8487
|
if self.active_laz.nb_points ==0:
|
@@ -8351,8 +8891,16 @@ class WolfMapViewer(wx.Frame):
|
|
8351
8891
|
self.frame_create1Dfrom2D = GuiNotebook1D(mapviewer= self)
|
8352
8892
|
logging.info(_(f'New window available - Wolf1D.'))
|
8353
8893
|
|
8354
|
-
elif
|
8894
|
+
elif itemlabel in [_('Create dike...'), _('Add dike...')]:
|
8895
|
+
self.new_dike(itemlabel)
|
8355
8896
|
|
8897
|
+
elif itemlabel in [_('Create a drowning...'), _('Add a drowning result...')]:
|
8898
|
+
|
8899
|
+
self.newdrowning(itemlabel)
|
8900
|
+
|
8901
|
+
|
8902
|
+
elif id == wx.ID_FILE7:
|
8903
|
+
autoscale = False
|
8356
8904
|
# Création de nouveaux vecteurs
|
8357
8905
|
newzones = Zones(parent=self)
|
8358
8906
|
self.add_object('vector', newobj=newzones)
|
@@ -8554,8 +9102,8 @@ class WolfMapViewer(wx.Frame):
|
|
8554
9102
|
if ret == wx.ID_OK:
|
8555
9103
|
obj.saveas(fdlg.GetPath())
|
8556
9104
|
|
8557
|
-
if len(self.myarrays) + len(self.myvectors) + len(self.myclouds) + len(self.mytri) + len(self.myres2D) + len(self.mytiles) + len(self.myimagestiles) + len(self.mypartsystems) == 2
|
8558
|
-
# Trouve les
|
9105
|
+
if len(self.myarrays) + len(self.myvectors) + len(self.myclouds) + len(self.mytri) + len(self.myres2D) + len(self.mytiles) + len(self.myimagestiles) + len(self.mypartsystems) + len(self.mydikes) + len(self.mydrownings) == 2 or autoscale:
|
9106
|
+
# Trouve les bornes si un seul élément est présent, sinon on conserve l'état du zoom
|
8559
9107
|
self.Autoscale()
|
8560
9108
|
|
8561
9109
|
def pop_boundary_manager(self, which:BcManager):
|
@@ -9131,7 +9679,9 @@ class WolfMapViewer(wx.Frame):
|
|
9131
9679
|
'particlesystem',
|
9132
9680
|
'wmsback',
|
9133
9681
|
'wmsfore',
|
9134
|
-
'
|
9682
|
+
'drowning',
|
9683
|
+
'imagestiles',
|
9684
|
+
'dike'] = 'array',
|
9135
9685
|
filename='',
|
9136
9686
|
newobj=None,
|
9137
9687
|
ToCheck=True,
|
@@ -9187,7 +9737,11 @@ class WolfMapViewer(wx.Frame):
|
|
9187
9737
|
elif which.lower() == 'res2d':
|
9188
9738
|
file = wx.FileDialog(self, "Choose file", wildcard=filterres2d)
|
9189
9739
|
elif which.lower() == 'res2d_gpu':
|
9190
|
-
file = wx.DirDialog(self, "Choose directory
|
9740
|
+
file = wx.DirDialog(self, "Choose directory containing WolfGPU results")
|
9741
|
+
elif which.lower() == 'drowning':
|
9742
|
+
file = wx.DirDialog(self, "Choose directory containing the drowning")
|
9743
|
+
elif which.lower() == 'dike':
|
9744
|
+
file = wx.DirDialog(self, "Choose directory", wildcard=filterall)
|
9191
9745
|
|
9192
9746
|
# FIXME : particularize filters for wmsback and wmsfore
|
9193
9747
|
elif which.lower() == 'wmsback':
|
@@ -9810,7 +10364,7 @@ class WolfMapViewer(wx.Frame):
|
|
9810
10364
|
self.myothers.append(newobj)
|
9811
10365
|
newobj.mapviewer = self
|
9812
10366
|
else:
|
9813
|
-
logging.warning('No object to add in "Other" category -- Please provide an object to add or check your code')
|
10367
|
+
logging.warning(_('No object to add in "Other" category -- Please provide an object to add or check your code'))
|
9814
10368
|
|
9815
10369
|
elif which.lower() == 'views':
|
9816
10370
|
|
@@ -9829,7 +10383,7 @@ class WolfMapViewer(wx.Frame):
|
|
9829
10383
|
curtree = self.myitemswmsback
|
9830
10384
|
self.mywmsback.append(newobj)
|
9831
10385
|
else:
|
9832
|
-
logging.warning('No object to add in "WMS background" category -- Please provide an object to add or check your code')
|
10386
|
+
logging.warning(_('No object to add in "WMS background" category -- Please provide an object to add or check your code'))
|
9833
10387
|
|
9834
10388
|
elif which.lower() == 'wmsfore':
|
9835
10389
|
|
@@ -9838,7 +10392,7 @@ class WolfMapViewer(wx.Frame):
|
|
9838
10392
|
curtree = self.myitemswmsfore
|
9839
10393
|
self.mywmsfore.append(newobj)
|
9840
10394
|
else:
|
9841
|
-
logging.warning('No object to add in "WMS foreground" category -- Please provide an object to add or check your code')
|
10395
|
+
logging.warning(_('No object to add in "WMS foreground" category -- Please provide an object to add or check your code'))
|
9842
10396
|
|
9843
10397
|
elif which.lower() == 'particlesystem':
|
9844
10398
|
|
@@ -9851,6 +10405,23 @@ class WolfMapViewer(wx.Frame):
|
|
9851
10405
|
self.mypartsystems.append(newobj)
|
9852
10406
|
self.active_particle_system = newobj
|
9853
10407
|
|
10408
|
+
elif which.lower() == 'drowning':
|
10409
|
+
|
10410
|
+
curdict = self.mydrownings
|
10411
|
+
curtree = self.myitemsdrowning
|
10412
|
+
|
10413
|
+
self.mydrownings.append(newobj)
|
10414
|
+
self.active_drowning = newobj
|
10415
|
+
|
10416
|
+
|
10417
|
+
elif which.lower() == 'dike':
|
10418
|
+
|
10419
|
+
curdict = self.mydikes
|
10420
|
+
curtree = self.myitemsdike
|
10421
|
+
|
10422
|
+
self.mydikes.append(newobj)
|
10423
|
+
self.active_dike = newobj
|
10424
|
+
|
9854
10425
|
# ID chooser
|
9855
10426
|
if id == '':
|
9856
10427
|
dlg = wx.TextEntryDialog(self, 'ID ? (case insensitive)', 'Choose an identifier', '')
|
@@ -9965,7 +10536,7 @@ class WolfMapViewer(wx.Frame):
|
|
9965
10536
|
|
9966
10537
|
if drawing_type is None:
|
9967
10538
|
# return all_lists
|
9968
|
-
return self.myarrays + self.myvectors + self.myclouds + self.mytri + self.mypartsystems + self.myothers + self.myviews + self.myres2D
|
10539
|
+
return self.myarrays + self.myvectors + self.myclouds + self.mytri + self.mypartsystems + self.myothers + self.myviews + self.myres2D + self.mydikes + self.mydrownings
|
9969
10540
|
|
9970
10541
|
if drawing_type == draw_type.ARRAYS:
|
9971
10542
|
return self.myarrays
|
@@ -9993,6 +10564,10 @@ class WolfMapViewer(wx.Frame):
|
|
9993
10564
|
return self.myimagestiles
|
9994
10565
|
elif drawing_type == draw_type.LAZ:
|
9995
10566
|
return self.mylazdata
|
10567
|
+
elif drawing_type == draw_type.DROWNING:
|
10568
|
+
return self.mydrownings
|
10569
|
+
elif drawing_type == draw_type.DIKE:
|
10570
|
+
return self.mydikes
|
9996
10571
|
else:
|
9997
10572
|
logging.error('Unknown drawing type : ' + drawing_type)
|
9998
10573
|
return None
|
@@ -10120,6 +10695,24 @@ class WolfMapViewer(wx.Frame):
|
|
10120
10695
|
|
10121
10696
|
self.removeobj_from_id(id)
|
10122
10697
|
|
10698
|
+
def checkuncheckobj(self):
|
10699
|
+
""" Check/uncheck selected item from general tree """
|
10700
|
+
|
10701
|
+
if self.selected_treeitem is None:
|
10702
|
+
return
|
10703
|
+
|
10704
|
+
id = self.treelist.GetItemText(self.selected_treeitem).lower()
|
10705
|
+
|
10706
|
+
current_check = self.treelist.GetCheckedState(self.selected_treeitem)
|
10707
|
+
myobj = self.getobj_from_id(id)
|
10708
|
+
if myobj is not None:
|
10709
|
+
if current_check == 0:
|
10710
|
+
self.treelist.CheckItem(self.selected_treeitem)
|
10711
|
+
myobj.check_plot()
|
10712
|
+
else:
|
10713
|
+
self.treelist.CheckItem(self.selected_treeitem, False)
|
10714
|
+
myobj.uncheck_plot()
|
10715
|
+
|
10123
10716
|
def removeobj_from_id(self, id:str):
|
10124
10717
|
""" Remove object from id """
|
10125
10718
|
|
@@ -10169,6 +10762,12 @@ class WolfMapViewer(wx.Frame):
|
|
10169
10762
|
elif myobj is self.active_zones:
|
10170
10763
|
self.active_zones = None
|
10171
10764
|
self.set_label_selecteditem('')
|
10765
|
+
elif myobj is self.active_drowning:
|
10766
|
+
self.active_drowning = None
|
10767
|
+
self.set_label_selecteditem('')
|
10768
|
+
elif myobj is self.active_dike:
|
10769
|
+
self.active_dike = None
|
10770
|
+
self.set_label_selecteditem('')
|
10172
10771
|
|
10173
10772
|
def upobj(self):
|
10174
10773
|
"""Up selected item into general tree"""
|
@@ -10297,6 +10896,11 @@ class WolfMapViewer(wx.Frame):
|
|
10297
10896
|
self.selected_object.saveas()
|
10298
10897
|
elif isinstance(self.selected_object, Particle_system):
|
10299
10898
|
self.selected_object.save()
|
10899
|
+
elif isinstance(self.selected_object, Drowning_victim_Viewer):
|
10900
|
+
self.selected_object.save()
|
10901
|
+
elif isinstance(self.selected_object, DikeWolf):
|
10902
|
+
self.selected_object.save()
|
10903
|
+
|
10300
10904
|
elif text==_('Up'):
|
10301
10905
|
self.upobj()
|
10302
10906
|
|
@@ -10306,6 +10910,9 @@ class WolfMapViewer(wx.Frame):
|
|
10306
10910
|
elif text == _('Delete'):
|
10307
10911
|
self.removeobj()
|
10308
10912
|
|
10913
|
+
elif text == ('Check/Uncheck'):
|
10914
|
+
self.checkuncheckobj()
|
10915
|
+
|
10309
10916
|
elif text == _('Rename'):
|
10310
10917
|
#Modification du nom de l'objet sélectionné
|
10311
10918
|
if self.selected_object is not None:
|
@@ -10439,6 +11046,8 @@ class WolfMapViewer(wx.Frame):
|
|
10439
11046
|
self.selected_object.save(fdlg.GetPath())
|
10440
11047
|
|
10441
11048
|
fdlg.Destroy()
|
11049
|
+
elif isinstance(self.selected_object, DikeWolf):
|
11050
|
+
self.selected_object.save_as()
|
10442
11051
|
|
10443
11052
|
elif isinstance(self.selected_object, Wolf_LAZ_Data):
|
10444
11053
|
filterArray = "Dump (*.dump)|*.dmp|all (*.*)|*.*"
|
@@ -10450,10 +11059,16 @@ class WolfMapViewer(wx.Frame):
|
|
10450
11059
|
|
10451
11060
|
fdlg.Destroy()
|
10452
11061
|
|
11062
|
+
elif isinstance(self.selected_object, Particle_system):
|
11063
|
+
self.selected_object.saveas()
|
11064
|
+
|
11065
|
+
elif isinstance(self.selected_object, Drowning_victim_Viewer):
|
11066
|
+
self.selected_object.saveas()
|
11067
|
+
|
10453
11068
|
elif text == _('Properties'):
|
10454
11069
|
|
10455
11070
|
myobj = self.selected_object
|
10456
|
-
if type(myobj) in [WolfArray, WolfArrayMB, WolfArrayMNAP, Zones, Wolfresults_2D, wolfres2DGPU, Particle_system, Picc_data, Cadaster_data, hydrometry_wolfgui, Bridge, Weir, Wolf_LAZ_Data]:
|
11071
|
+
if type(myobj) in [WolfArray, WolfArrayMB, WolfArrayMNAP, Zones, Wolfresults_2D, wolfres2DGPU, Particle_system, Picc_data, Cadaster_data, hydrometry_wolfgui, Bridge, Weir, Wolf_LAZ_Data, DikeWolf, Drowning_victim_Viewer]:
|
10457
11072
|
myobj.show_properties()
|
10458
11073
|
|
10459
11074
|
elif isinstance(myobj, cloud_vertices):
|
@@ -10802,9 +11417,10 @@ class WolfMapViewer(wx.Frame):
|
|
10802
11417
|
|
10803
11418
|
self.treelist.SetToolTip(self.treelist.GetItemText(myitem))
|
10804
11419
|
|
10805
|
-
myparent = self.treelist.GetItemParent(myitem)
|
10806
|
-
check = self.treelist.GetCheckedState(myitem)
|
10807
|
-
|
11420
|
+
# myparent = self.treelist.GetItemParent(myitem)
|
11421
|
+
# check = self.treelist.GetCheckedState(myitem)
|
11422
|
+
# if myparent is not None:
|
11423
|
+
# nameparent = self.treelist.GetItemText(myparent).lower()
|
10808
11424
|
|
10809
11425
|
self.selected_object = curobj
|
10810
11426
|
self.selected_treeitem = myitem
|
@@ -10947,6 +11563,7 @@ class WolfMapViewer(wx.Frame):
|
|
10947
11563
|
We use this event to manage "action" set by others objects.
|
10948
11564
|
|
10949
11565
|
"""
|
11566
|
+
#self._user_activity_true()
|
10950
11567
|
|
10951
11568
|
pos = e.GetPosition()
|
10952
11569
|
x, y = self.getXY(pos)
|
@@ -11366,6 +11983,9 @@ class WolfMapViewer(wx.Frame):
|
|
11366
11983
|
|
11367
11984
|
|
11368
11985
|
def On_Mouse_Right_Up(self, e):
|
11986
|
+
|
11987
|
+
#self._user_activity_true()
|
11988
|
+
|
11369
11989
|
pos = e.GetPosition()
|
11370
11990
|
x, y = self.getXY(pos)
|
11371
11991
|
|
@@ -11394,6 +12014,9 @@ class WolfMapViewer(wx.Frame):
|
|
11394
12014
|
pass
|
11395
12015
|
|
11396
12016
|
def On_Mouse_Button(self, e: wx.MouseEvent):
|
12017
|
+
|
12018
|
+
#self._user_activity_true()
|
12019
|
+
|
11397
12020
|
d = e.GetWheelDelta()
|
11398
12021
|
r = e.GetWheelRotation()
|
11399
12022
|
a = e.GetWheelAxis()
|
@@ -11502,6 +12125,7 @@ class WolfMapViewer(wx.Frame):
|
|
11502
12125
|
|
11503
12126
|
def On_Mouse_Left_Down(self, e):
|
11504
12127
|
""" Event when the left button of the mouse is pressed """
|
12128
|
+
#self._user_activity_true()
|
11505
12129
|
|
11506
12130
|
# if not self.move:
|
11507
12131
|
pos = e.GetPosition()
|
@@ -11509,6 +12133,14 @@ class WolfMapViewer(wx.Frame):
|
|
11509
12133
|
self.mousedown = (x, y)
|
11510
12134
|
# self.move = True
|
11511
12135
|
|
12136
|
+
def On_Mouse_Left_Up(self, e):
|
12137
|
+
""" Event when the left button of the mouse is released """
|
12138
|
+
|
12139
|
+
pass
|
12140
|
+
# if self._thread_update_background is None:
|
12141
|
+
# self._thread_update_background = threading.Thread(target=self.background_task, args=[self]) # thread to update the background
|
12142
|
+
# self._thread_update_background.start() # start the thread
|
12143
|
+
|
11512
12144
|
def _set_active_bc(self):
|
11513
12145
|
"""Search and activate BCManager according to active_array"""
|
11514
12146
|
if self.active_bc is not None:
|
@@ -11671,6 +12303,13 @@ class WolfMapViewer(wx.Frame):
|
|
11671
12303
|
if ctrl:
|
11672
12304
|
myobj.show_properties()
|
11673
12305
|
|
12306
|
+
elif type(myobj) == Drowning_victim_Viewer:
|
12307
|
+
logging.info(_('Activating Drowning victim event : ' + nameitem))
|
12308
|
+
self.active_drowning = myobj
|
12309
|
+
|
12310
|
+
if ctrl:
|
12311
|
+
myobj.show_properties()
|
12312
|
+
|
11674
12313
|
def _update_mytooltip(self):
|
11675
12314
|
""" Update the tooltip with the values of the active arrays and results at position x,y """
|
11676
12315
|
|
@@ -11978,12 +12617,42 @@ class WolfMapViewer(wx.Frame):
|
|
11978
12617
|
except:
|
11979
12618
|
pass
|
11980
12619
|
|
11981
|
-
self.
|
12620
|
+
for loc_drowning in self.mydrownings:
|
12621
|
+
if loc_drowning.checked:
|
12622
|
+
try:
|
12623
|
+
if loc_drowning.bottom_cells is not None:
|
12624
|
+
curgroup = loc_drowning.idx
|
12625
|
+
try:
|
12626
|
+
i_bottom, j_bottom = loc_drowning.bottom_cells.get_ij_from_xy(x, y)
|
12627
|
+
i_surface, j_surface = loc_drowning.surface_cells.get_ij_from_xy(x, y)
|
12628
|
+
except:
|
12629
|
+
pass
|
12630
|
+
value = loc_drowning.bottom_cells.array[i_bottom,j_bottom]
|
12631
|
+
if not np.ma.is_masked(value) and value >0:
|
12632
|
+
self.mytooltip.add_param(groupname = curgroup,
|
12633
|
+
name = 'Bottom - percentage of the whole sample',
|
12634
|
+
value = value,
|
12635
|
+
type = Type_Param.Float,
|
12636
|
+
comment = '')
|
12637
|
+
value = loc_drowning.surface_cells.array[i_surface,j_surface]
|
12638
|
+
if not np.ma.is_masked(value) and value >0:
|
12639
|
+
self.mytooltip.add_param(groupname = curgroup,
|
12640
|
+
name = 'Surface - percentage of the whole sample',
|
12641
|
+
value = value,
|
12642
|
+
type = Type_Param.Float,
|
12643
|
+
comment = '')
|
12644
|
+
except:
|
12645
|
+
pass
|
11982
12646
|
|
11983
12647
|
|
12648
|
+
self.mytooltip.PopulateOnePage()
|
12649
|
+
|
11984
12650
|
def On_Mouse_Motion(self, e: wx.MouseEvent):
|
11985
12651
|
""" Mouse move event """
|
11986
12652
|
|
12653
|
+
|
12654
|
+
#self._user_activity_true()
|
12655
|
+
|
11987
12656
|
# Déplacement de la souris sur le canvas OpenGL
|
11988
12657
|
posframe = self.GetPosition() # Get the position of the frame -> useful to set the tooltip position
|
11989
12658
|
pos = e.GetPosition() # Get the position of the mouse in the canvas
|
@@ -13094,6 +13763,7 @@ class WolfMapViewer(wx.Frame):
|
|
13094
13763
|
self.active_particle_system = None
|
13095
13764
|
self.active_vertex = None
|
13096
13765
|
self.active_cloud = None
|
13766
|
+
self.active_dike = None
|
13097
13767
|
|
13098
13768
|
self.active_laz = None
|
13099
13769
|
|
@@ -13481,22 +14151,36 @@ class WolfMapViewer(wx.Frame):
|
|
13481
14151
|
self.height = ymax - ymin
|
13482
14152
|
|
13483
14153
|
self.setbounds()
|
14154
|
+
self.update()
|
13484
14155
|
|
13485
14156
|
|
13486
|
-
def
|
14157
|
+
def _update_background(self):
|
13487
14158
|
"""
|
13488
|
-
Update
|
13489
|
-
|
14159
|
+
Update background
|
13490
14160
|
"""
|
13491
14161
|
|
13492
14162
|
# dessin du background
|
13493
14163
|
for obj in self.iterator_over_objects(draw_type.WMSBACK):
|
13494
14164
|
obj.reload()
|
13495
14165
|
|
14166
|
+
def _update_foreground(self):
|
14167
|
+
"""
|
14168
|
+
Update foreground
|
14169
|
+
"""
|
13496
14170
|
# dessin du foreground
|
13497
14171
|
for obj in self.iterator_over_objects(draw_type.WMSFORE):
|
13498
14172
|
obj.reload()
|
13499
14173
|
|
14174
|
+
def update(self):
|
14175
|
+
"""
|
14176
|
+
Update backgournd et foreground elements and arrays if local minmax is checked.
|
14177
|
+
|
14178
|
+
"""
|
14179
|
+
|
14180
|
+
self._update_background()
|
14181
|
+
|
14182
|
+
self._update_foreground()
|
14183
|
+
|
13500
14184
|
if self.locminmax.IsChecked() or self.update_absolute_minmax:
|
13501
14185
|
for curarray in self.iterator_over_objects(draw_type.ARRAYS):
|
13502
14186
|
curarray: WolfArray
|
@@ -13616,6 +14300,9 @@ class WolfMapViewer(wx.Frame):
|
|
13616
14300
|
# Dessin du reste
|
13617
14301
|
self._plotting(draw_type.OTHER)
|
13618
14302
|
|
14303
|
+
# Dessin du noyé
|
14304
|
+
self._plotting(draw_type.DROWNING)
|
14305
|
+
|
13619
14306
|
# Dessin du Front
|
13620
14307
|
self._plotting(draw_type.WMSFORE)
|
13621
14308
|
|
@@ -13654,10 +14341,11 @@ class WolfMapViewer(wx.Frame):
|
|
13654
14341
|
k = 0
|
13655
14342
|
for locarray in self.myarrays:
|
13656
14343
|
if locarray.plotted or force:
|
13657
|
-
|
13658
|
-
|
13659
|
-
|
13660
|
-
|
14344
|
+
[xmin_arr, xmax_arr], [ymin_arr, ymax_arr] = locarray.get_bounds()
|
14345
|
+
xmin = min(xmin, xmin_arr)
|
14346
|
+
xmax = max(xmax, xmax_arr)
|
14347
|
+
ymin = min(ymin, ymin_arr)
|
14348
|
+
ymax = max(ymax, ymax_arr)
|
13661
14349
|
k += 1
|
13662
14350
|
|
13663
14351
|
for locvector in self.myvectors:
|
@@ -13773,6 +14461,16 @@ class WolfMapViewer(wx.Frame):
|
|
13773
14461
|
ymax = max(locothers.ymax, ymax)
|
13774
14462
|
k += 1
|
13775
14463
|
|
14464
|
+
for drown in self.mydrownings:
|
14465
|
+
if drown.plotted or force:
|
14466
|
+
drown.find_minmax(force)
|
14467
|
+
xmin = min(drown.xmin, xmin)
|
14468
|
+
xmax = max(drown.xmax, xmax)
|
14469
|
+
ymin = min(drown.ymin, ymin)
|
14470
|
+
ymax = max(drown.ymax, ymax)
|
14471
|
+
k += 1
|
14472
|
+
|
14473
|
+
|
13776
14474
|
if k > 0:
|
13777
14475
|
self.xmin = xmin
|
13778
14476
|
self.xmax = xmax
|