wolfhece 2.1.107__py3-none-any.whl → 2.1.109__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/PyDraw.py +165 -14
- wolfhece/PyGui.py +1 -1
- wolfhece/PyVertex.py +17 -1
- wolfhece/PyVertexvectors.py +676 -112
- wolfhece/PyWMS.py +61 -1
- wolfhece/acceptability/acceptability.py +59 -51
- wolfhece/acceptability/acceptability_gui.py +1043 -153
- wolfhece/acceptability/func.py +83 -48
- wolfhece/apps/version.py +1 -1
- wolfhece/lazviewer/laz_viewer.py +22 -0
- wolfhece/matplotlib_fig.py +69 -20
- wolfhece/picc.py +2 -2
- wolfhece/pybridges.py +227 -87
- wolfhece/scenario/config_manager.py +25 -6
- wolfhece/wolf_array.py +94 -40
- wolfhece/wolf_texture.py +12 -3
- wolfhece/wolf_tiles.py +2 -0
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.109.dist-info}/METADATA +2 -2
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.109.dist-info}/RECORD +22 -22
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.109.dist-info}/WHEEL +1 -1
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.109.dist-info}/entry_points.txt +0 -0
- {wolfhece-2.1.107.dist-info → wolfhece-2.1.109.dist-info}/top_level.txt +0 -0
wolfhece/acceptability/func.py
CHANGED
@@ -186,7 +186,6 @@ class Accept_Manager():
|
|
186
186
|
|
187
187
|
self.IN_DIR = self.main_dir / "INPUT"
|
188
188
|
self.IN_CH_VULN = self.IN_DIR / "CHANGE_VULNE"
|
189
|
-
self.IN_CH_SA_SC = self.IN_CH_VULN / str(Study_area).rsplit('.', 1)[0] / str(scenario)
|
190
189
|
self.IN_DATABASE = self.IN_DIR / "DATABASE"
|
191
190
|
self.IN_STUDY_AREA = self.IN_DIR / "STUDY_AREA"
|
192
191
|
self.IN_CSV = self.IN_DIR / "CSVs"
|
@@ -290,11 +289,17 @@ class Accept_Manager():
|
|
290
289
|
|
291
290
|
self.scenario:str = str(self._scenario)
|
292
291
|
|
292
|
+
|
293
|
+
self.IN_SA_BASE = self.IN_WATER_DEPTH / self.SA.stem / "Scenario_baseline"
|
294
|
+
self.IN_SA_BASE_INTERP = self.IN_SA_BASE / "INTERP_WD"
|
295
|
+
|
293
296
|
self.IN_SCEN_DIR = self.IN_WATER_DEPTH / self.SA.stem / self.scenario
|
294
|
-
self.IN_SA_Base = self.IN_WATER_DEPTH / self.SA.stem / "Scenario_baseline"
|
295
297
|
self.IN_SA_INTERP = self.IN_SCEN_DIR / "INTERP_WD"
|
296
298
|
self.IN_SA_EXTRACTED = self.IN_SCEN_DIR / "EXTRACTED_LAST_STEP_WD"
|
297
|
-
self.IN_SA_DEM = self.IN_SCEN_DIR / "DEM_FILES"
|
299
|
+
self.IN_SA_DEM = self.IN_SCEN_DIR / "DEM_FILES"
|
300
|
+
self.IN_CH_SA_SC = self.IN_CH_VULN /self.SA.stem / self.scenario
|
301
|
+
self.IN_CH_SA_SC_MNT_VRT = self.IN_CH_SA_SC / "__MNT_assembly.vrt"
|
302
|
+
self.IN_CH_SA_SC_MNT_tif = self.IN_CH_SA_SC / "MNTassembly"
|
298
303
|
|
299
304
|
self.IN_RM_BUILD_DIR = self.IN_SCEN_DIR / "REMOVED_BUILDINGS"
|
300
305
|
|
@@ -302,21 +307,26 @@ class Accept_Manager():
|
|
302
307
|
self.TMP_RM_BUILD_DIR = self.TMP_SCEN_DIR / "REMOVED_BUILDINGS"
|
303
308
|
self.TMP_QFILES = self.TMP_SCEN_DIR / "Q_FILES"
|
304
309
|
|
305
|
-
self.TMP_VULN = self.TMP_SCEN_DIR / "
|
306
|
-
self.TMP_CODE = self.TMP_SCEN_DIR / "
|
310
|
+
self.TMP_VULN = self.TMP_SCEN_DIR / "Vulnerability_baseline.tiff"
|
311
|
+
self.TMP_CODE = self.TMP_SCEN_DIR / "Vulnerability_Code_baseline.tiff"
|
307
312
|
|
308
313
|
self.OUT_SCEN_DIR = self.OUT_STUDY_AREA / self.scenario
|
309
314
|
|
310
|
-
self.
|
311
|
-
self.OUT_VULN_VRT = self.
|
312
|
-
self.OUT_VULN_S = self.
|
313
|
-
self.OUT_VULN_Stif = self.
|
314
|
-
self.
|
315
|
-
self.
|
316
|
-
self.
|
317
|
-
|
318
|
-
self.
|
319
|
-
self.
|
315
|
+
self.OUT_WITHVULN = self.OUT_SCEN_DIR / "vuln_ scenarios"
|
316
|
+
self.OUT_VULN_VRT = self.OUT_WITHVULN / "__vuln_assembly.vrt"
|
317
|
+
self.OUT_VULN_S = self.OUT_WITHVULN / "Vulnerability_scenarios"
|
318
|
+
self.OUT_VULN_Stif = self.OUT_WITHVULN / "Vulnerability_scenarios.tif"
|
319
|
+
self.OUT_MASKED_RIVER_S = self.OUT_WITHVULN / "Masked_River_extent_scenarios.tiff"
|
320
|
+
self.OUT_ACCEPT_Stif = self.OUT_WITHVULN / "Acceptability_scenarios.tiff"
|
321
|
+
self.OUT_ACCEPT_RESAMP_Stif = self.OUT_WITHVULN / "Acceptability_scenarios_resampled.tiff"
|
322
|
+
|
323
|
+
self.OUT_BASELINE = self.OUT_SCEN_DIR / "baseline"
|
324
|
+
self.OUT_VULN = self.OUT_BASELINE / "Vulnerability_baseline.tiff"
|
325
|
+
self.OUT_CODE = self.OUT_BASELINE / "Vulnerability_Code_baseline.tiff"
|
326
|
+
self.OUT_MASKED_RIVER = self.OUT_BASELINE / "Masked_River_extent_baseline.tiff"
|
327
|
+
self.OUT_ACCEPT = self.OUT_BASELINE / "Acceptability_baseline.tiff"
|
328
|
+
self.OUT_ACCEPT_RESAMP = self.OUT_BASELINE / "Acceptability_baseline_resampled.tiff"
|
329
|
+
|
320
330
|
else:
|
321
331
|
self.scenario = None
|
322
332
|
|
@@ -330,12 +340,20 @@ class Accept_Manager():
|
|
330
340
|
self.TMP_VULN = None
|
331
341
|
self.TMP_CODE = None
|
332
342
|
|
333
|
-
self.OUT_SCEN_DIR
|
334
|
-
self.
|
335
|
-
self.
|
336
|
-
self.
|
337
|
-
self.
|
338
|
-
self.
|
343
|
+
self.OUT_SCEN_DIR = None
|
344
|
+
self.OUT_WITHVULN = None
|
345
|
+
self.OUT_VULN_VRT = None
|
346
|
+
self.OUT_VULN_S = None
|
347
|
+
self.OUT_VULN_Stif = None
|
348
|
+
self.OUT_MASKED_RIVER_S = None
|
349
|
+
self.OUT_ACCEPT_Stif = None
|
350
|
+
self.OUT_ACCEPT_RESAMP_Stif = None
|
351
|
+
self.OUT_BASELINE = None
|
352
|
+
self.OUT_VULN = None
|
353
|
+
self.OUT_CODE = None
|
354
|
+
self.OUT_MASKED_RIVER = None
|
355
|
+
self.OUT_ACCEPT = None
|
356
|
+
self.OUT_ACCEPT_RESAMP = None
|
339
357
|
|
340
358
|
@property
|
341
359
|
def is_valid_inputs(self) -> bool:
|
@@ -437,17 +455,17 @@ class Accept_Manager():
|
|
437
455
|
if self.IN_SA_INTERP.exists() :
|
438
456
|
files = [Path(a) for a in glob.glob(str(self.IN_SA_INTERP / "*.tif"))]
|
439
457
|
else :
|
440
|
-
logging.error("No
|
458
|
+
logging.error("No such scenario")
|
441
459
|
return files
|
442
460
|
|
443
461
|
def get_sims_files_for_baseline(self) -> list[Path]:
|
444
462
|
files = [] #to avoid NoneType
|
445
|
-
if self.
|
446
|
-
logging.info("Getting the _baseline
|
447
|
-
track = Path(str(self.
|
463
|
+
if self.IN_SA_BASE_INTERP.exists() :
|
464
|
+
logging.info("Getting the _baseline interpolated free surfaces files.")
|
465
|
+
track = Path(str(self.IN_SA_BASE_INTERP / "*.tif"))
|
448
466
|
files = [Path(a) for a in glob.glob(str(track))]
|
449
467
|
else :
|
450
|
-
logging.error("No _baseline
|
468
|
+
logging.error("No _baseline interpolated free surfaces files")
|
451
469
|
|
452
470
|
return files
|
453
471
|
|
@@ -591,8 +609,8 @@ class Accept_Manager():
|
|
591
609
|
return None
|
592
610
|
|
593
611
|
if len(rt)<2:
|
594
|
-
logging.info("
|
595
|
-
return
|
612
|
+
logging.info("There is only one simulation!")
|
613
|
+
return pd.DataFrame(1, columns=["Ponderation"], index=rt)
|
596
614
|
|
597
615
|
else :
|
598
616
|
pond = []
|
@@ -723,6 +741,9 @@ class Accept_Manager():
|
|
723
741
|
|
724
742
|
if self.scenario is not None:
|
725
743
|
self.OUT_SCEN_DIR.mkdir(parents=True, exist_ok=True)
|
744
|
+
self.OUT_WITHVULN.mkdir(parents=True, exist_ok=True)
|
745
|
+
self.OUT_BASELINE.mkdir(parents=True, exist_ok=True)
|
746
|
+
|
726
747
|
|
727
748
|
return True
|
728
749
|
|
@@ -938,11 +959,11 @@ class Accept_Manager():
|
|
938
959
|
the search of a more specific word ('vuln', and not 'bath', 'mann', or 'inf').
|
939
960
|
"""
|
940
961
|
|
941
|
-
def
|
962
|
+
def tree_name_tif(folder_path, name):
|
942
963
|
"""Find all .tiff files starting with 'vuln' in the directory and return paths"""
|
943
964
|
folder = Path(folder_path)
|
944
|
-
vuln_tiff_files = {file for file in folder.rglob("*.tiff") if file.name.startswith(
|
945
|
-
vuln_tif_files = {file for file in folder.rglob("*.tif") if file.name.startswith(
|
965
|
+
vuln_tiff_files = {file for file in folder.rglob("*.tiff") if file.name.startswith(name)}
|
966
|
+
vuln_tif_files = {file for file in folder.rglob("*.tif") if file.name.startswith(name)}
|
946
967
|
|
947
968
|
vuln_files = vuln_tiff_files.union(vuln_tif_files)
|
948
969
|
|
@@ -956,24 +977,24 @@ class Accept_Manager():
|
|
956
977
|
tiff_trees.append(curtree)
|
957
978
|
return tiff_trees
|
958
979
|
|
959
|
-
def
|
980
|
+
def select_name_tif(self, path_baseline: Path, folder_path: Path, name) -> list[Path]:
|
960
981
|
"""
|
961
982
|
Collects and appends all .tiff files starting with 'vuln' from folder_path into a list.
|
962
983
|
"""
|
963
984
|
files = []
|
964
985
|
#first element must be vulnerability_baseline
|
965
986
|
files.append(path_baseline.as_posix())
|
966
|
-
tiff_trees = Accept_Manager.
|
987
|
+
tiff_trees = Accept_Manager.tree_name_tif(folder_path, name)
|
967
988
|
|
968
989
|
#only the 'final' path of the tree
|
969
990
|
for tree in tiff_trees:
|
970
991
|
files.append(tree[-1].as_posix())
|
971
992
|
return files
|
972
993
|
|
973
|
-
def check_nodata(self):
|
994
|
+
def check_nodata(self, name):
|
974
995
|
""" Check nodata in a path """
|
975
996
|
|
976
|
-
list_tif = Accept_Manager.
|
997
|
+
list_tif = Accept_Manager.select_name_tif(self, self.OUT_VULN, self.IN_CH_SA_SC, name)
|
977
998
|
for cur_lst in list_tif:
|
978
999
|
if "Vulnerability.tiff" not in cur_lst:
|
979
1000
|
curarray:WolfArray = WolfArray(cur_lst)
|
@@ -983,24 +1004,25 @@ class Accept_Manager():
|
|
983
1004
|
curarray.write_all()
|
984
1005
|
logging.warning(_('nodata changed in favor of 99999. value for file {} !'.format(cur_lst)))
|
985
1006
|
|
986
|
-
def create_vrtIfExists(self):
|
1007
|
+
def create_vrtIfExists(self, fn_baseline, fn_scenario, fn_vrt, name):
|
987
1008
|
""" Create a vrt file from a path """
|
988
1009
|
logging.info(_('Checking nodata values...'))
|
989
|
-
self.check_nodata()
|
990
|
-
list_tif = Accept_Manager.
|
1010
|
+
self.check_nodata(name)
|
1011
|
+
list_tif = Accept_Manager.select_name_tif(self, fn_baseline, fn_scenario, name)
|
991
1012
|
#création du fichier vrt - assembly/agglomération
|
992
1013
|
if len(list_tif)>1:
|
993
1014
|
logging.info(_('Creating .vrt from files (first based)...'))
|
994
|
-
create_vrt_from_diverged_files_first_based(list_tif,
|
1015
|
+
create_vrt_from_diverged_files_first_based(list_tif, fn_vrt)
|
995
1016
|
return True
|
996
1017
|
else:
|
997
1018
|
return False
|
998
1019
|
|
999
1020
|
|
1000
|
-
def translate_vrt2tif(self):
|
1001
|
-
""" Translate vrt from OUTPUT > ... > Scenario to tif saved in the same folder """
|
1002
|
-
if (
|
1003
|
-
translate_vrt2tif(
|
1021
|
+
def translate_vrt2tif(self, fn_VRT, fn_vuln_s):
|
1022
|
+
""" Translate vrt from OUTPUT > ... > Scenario to tif saved in the same folder, and delete the vrt file """
|
1023
|
+
if (fn_VRT).exists():
|
1024
|
+
translate_vrt2tif(fn_VRT, fn_vuln_s)
|
1025
|
+
os.remove(fn_VRT)
|
1004
1026
|
|
1005
1027
|
def copy_tif_files(self, files: list[Path], destination_dir: Path) -> None:
|
1006
1028
|
destination_dir.mkdir(parents=True, exist_ok=True)
|
@@ -1016,7 +1038,20 @@ class Accept_Manager():
|
|
1016
1038
|
|
1017
1039
|
dataset = None
|
1018
1040
|
|
1019
|
-
logging.info("All .tif files have been copied to the destination directory.")
|
1041
|
+
logging.info("All the existing .tif files have been copied to the destination directory.")
|
1042
|
+
|
1043
|
+
def wich_river_trace(self):
|
1044
|
+
""" Searches for existing riverbed traces: if none ending with '_scenarios' are found, it selects the baseline trace."""
|
1045
|
+
trace = None
|
1046
|
+
if os.path.exists(self.OUT_MASKED_RIVER):
|
1047
|
+
trace = self.OUT_MASKED_RIVER
|
1048
|
+
if os.path.exists(self.OUT_MASKED_RIVER_S):
|
1049
|
+
trace = self.OUT_MASKED_RIVER_S
|
1050
|
+
else :
|
1051
|
+
logging.error("No Masked_River_extent files. Please provide them.")
|
1052
|
+
return trace
|
1053
|
+
|
1054
|
+
|
1020
1055
|
|
1021
1056
|
|
1022
1057
|
def clip_layer(layer:str,
|
@@ -1287,7 +1322,7 @@ def compute_vulnerability(manager:Accept_Manager):
|
|
1287
1322
|
return array_vuln
|
1288
1323
|
|
1289
1324
|
for i in tqdm(range(len(rasters_vuln)), 'Computing Vulnerability : '):
|
1290
|
-
logging.info("Computing layer {} / {}".format(i, len(rasters_vuln)))
|
1325
|
+
#logging.info("Computing layer {} / {}".format(i, len(rasters_vuln)))
|
1291
1326
|
|
1292
1327
|
locvuln = vuln_csv.get_vulnerability_level(rasters_vuln[i].stem)
|
1293
1328
|
|
@@ -1378,7 +1413,7 @@ def compute_code(manager:Accept_Manager):
|
|
1378
1413
|
return array_code
|
1379
1414
|
|
1380
1415
|
for i in tqdm(range(len(rasters_code)), 'Computing Code : '):
|
1381
|
-
logging.info("Computing layer {} / {}".format(i, len(rasters_code)))
|
1416
|
+
#logging.info("Computing layer {} / {}".format(i, len(rasters_code)))
|
1382
1417
|
|
1383
1418
|
loccode = vuln_csv.get_vulnerability_code(rasters_code[i].stem.removesuffix("_CODE"))
|
1384
1419
|
|
@@ -1481,7 +1516,7 @@ def match_vulnerability2sim(inRas:Path, outRas:Path, MODREC:Path):
|
|
1481
1516
|
:param MODREC: the MODREC/simulation extent file
|
1482
1517
|
|
1483
1518
|
"""
|
1484
|
-
|
1519
|
+
|
1485
1520
|
inRas = str(inRas)
|
1486
1521
|
outRas = str(outRas)
|
1487
1522
|
MODREC = str(MODREC)
|
@@ -1525,7 +1560,7 @@ def compute_acceptability(manager:Accept_Manager,
|
|
1525
1560
|
|
1526
1561
|
"""
|
1527
1562
|
|
1528
|
-
logging.info(interval)
|
1563
|
+
#logging.info(interval)
|
1529
1564
|
|
1530
1565
|
points_accept = pd.read_csv(manager.POINTS_CSV)
|
1531
1566
|
|
wolfhece/apps/version.py
CHANGED
wolfhece/lazviewer/laz_viewer.py
CHANGED
@@ -23,6 +23,7 @@ from ..PyWMS import getWalonmap
|
|
23
23
|
from ..PyTranslate import _
|
24
24
|
from ..color_constants import Colors
|
25
25
|
from ..PyParams import Wolf_Param
|
26
|
+
from ..matplotlib_fig import Matplotlib_Figure as mplfig
|
26
27
|
|
27
28
|
"""
|
28
29
|
Importation et visualisation de données LAS et LAZ
|
@@ -620,6 +621,27 @@ class xyz_laz_grids():
|
|
620
621
|
|
621
622
|
return fig,ax
|
622
623
|
|
624
|
+
def plot_laz_wx(self, xy:Union[LineString, list[list[float], list[float]]], length_buffer=5., show=True):
|
625
|
+
"""
|
626
|
+
Dessin des points LAZ sur un graphique Matplotlib
|
627
|
+
"""
|
628
|
+
|
629
|
+
(up_s, up_z, up_color), (down_s, down_z, down_color) = self.scan_around(xy, length_buffer)
|
630
|
+
|
631
|
+
figmpl = mplfig()
|
632
|
+
figmpl.presets()
|
633
|
+
fig = figmpl.fig
|
634
|
+
ax = figmpl.cur_ax
|
635
|
+
|
636
|
+
logging.info(_('Plotting'))
|
637
|
+
ax.scatter(up_s, up_z, c=up_color ,marker='.')
|
638
|
+
ax.scatter(down_s, down_z,c=down_color,marker='+')
|
639
|
+
|
640
|
+
if show:
|
641
|
+
figmpl.Show()
|
642
|
+
|
643
|
+
return figmpl
|
644
|
+
|
623
645
|
def create_from_laz(self, dir_laz:str, shape:str, ds:float = 50, force_format = np.float64):
|
624
646
|
|
625
647
|
try:
|
wolfhece/matplotlib_fig.py
CHANGED
@@ -1053,6 +1053,7 @@ class Matplotlib_Figure(wx.Frame):
|
|
1053
1053
|
self.ax_dict:dict[str,Axes] = {} # dict of axes
|
1054
1054
|
self.ax:list[Axes] = [] # list of axes -- always flatten
|
1055
1055
|
self.shown_props = None # shown properties
|
1056
|
+
self._shiftdown = False
|
1056
1057
|
|
1057
1058
|
self.apply_layout(layout) # apply the layout
|
1058
1059
|
pass
|
@@ -1192,6 +1193,7 @@ class Matplotlib_Figure(wx.Frame):
|
|
1192
1193
|
self._canvas.mpl_connect('motion_notify_event', self.UpdateStatusBar)
|
1193
1194
|
self._canvas.mpl_connect('button_press_event', self.OnClickCanvas)
|
1194
1195
|
self._canvas.mpl_connect('key_press_event', self.OnKeyCanvas)
|
1196
|
+
self._canvas.mpl_connect('key_release_event', self.OnKeyRelease)
|
1195
1197
|
|
1196
1198
|
# Toolbar - Matplotlib
|
1197
1199
|
# --------------------
|
@@ -1280,6 +1282,9 @@ class Matplotlib_Figure(wx.Frame):
|
|
1280
1282
|
self._add_row = wx.Button(win, -1, 'Add rows')
|
1281
1283
|
self._add_row.Bind(wx.EVT_BUTTON, self.add_row_to_grid)
|
1282
1284
|
|
1285
|
+
self._new_line = wx.Button(win, -1, 'New line')
|
1286
|
+
self._new_line.Bind(wx.EVT_BUTTON, self.onnew_line)
|
1287
|
+
|
1283
1288
|
self._add_line = wx.Button(win, -1, 'Add line')
|
1284
1289
|
self._add_line.Bind(wx.EVT_BUTTON, self.onadd_line)
|
1285
1290
|
|
@@ -1287,10 +1292,19 @@ class Matplotlib_Figure(wx.Frame):
|
|
1287
1292
|
self._del_line.Bind(wx.EVT_BUTTON, self.ondel_line)
|
1288
1293
|
|
1289
1294
|
self._sizer_xls.Add(self._xls, 1, wx.EXPAND)
|
1290
|
-
|
1291
|
-
self.
|
1292
|
-
self.
|
1293
|
-
|
1295
|
+
|
1296
|
+
self._sizer_update_add = wx.BoxSizer(wx.HORIZONTAL)
|
1297
|
+
self._sizer_add_remove = wx.BoxSizer(wx.HORIZONTAL)
|
1298
|
+
|
1299
|
+
self._sizer_xls.Add(self._sizer_update_add, 0, wx.EXPAND)
|
1300
|
+
self._sizer_xls.Add(self._sizer_add_remove, 0, wx.EXPAND)
|
1301
|
+
|
1302
|
+
self._sizer_update_add.Add(self._update_xy, 1, wx.EXPAND)
|
1303
|
+
self._sizer_update_add.Add(self._add_row, 1, wx.EXPAND)
|
1304
|
+
|
1305
|
+
self._sizer_add_remove.Add(self._new_line, 1, wx.EXPAND)
|
1306
|
+
self._sizer_add_remove.Add(self._add_line, 1, wx.EXPAND)
|
1307
|
+
self._sizer_add_remove.Add(self._del_line, 1, wx.EXPAND)
|
1294
1308
|
|
1295
1309
|
# Properties sizer
|
1296
1310
|
# ---------------
|
@@ -1519,6 +1533,12 @@ class Matplotlib_Figure(wx.Frame):
|
|
1519
1533
|
|
1520
1534
|
if event.key == 'escape':
|
1521
1535
|
self._axes_properties[int(self._ax_current.GetSelection())].reset_selection()
|
1536
|
+
elif event.key == 'shift':
|
1537
|
+
self._shiftdown = True
|
1538
|
+
|
1539
|
+
def OnKeyRelease(self, event:KeyEvent):
|
1540
|
+
if event.key == 'shift':
|
1541
|
+
self._shiftdown = False
|
1522
1542
|
|
1523
1543
|
def OnClickCanvas(self, event:MouseEvent):
|
1524
1544
|
|
@@ -1533,21 +1553,33 @@ class Matplotlib_Figure(wx.Frame):
|
|
1533
1553
|
idx= ax.get_figure().axes.index(event.inaxes)
|
1534
1554
|
x, y = event.xdata, event.ydata
|
1535
1555
|
|
1536
|
-
|
1537
|
-
line_min = None
|
1556
|
+
if rclick and not self._shiftdown:
|
1538
1557
|
|
1539
|
-
|
1540
|
-
|
1541
|
-
dist = np.linalg.norm(xy - np.array([x,y]), axis=1)
|
1542
|
-
idx_min = np.argmin(dist)
|
1543
|
-
if dist[idx_min] < dist_min:
|
1544
|
-
dist_min = dist[idx_min]
|
1545
|
-
line_min = line
|
1558
|
+
dist_min = 1e6
|
1559
|
+
line_min = None
|
1546
1560
|
|
1547
|
-
|
1548
|
-
|
1549
|
-
|
1550
|
-
|
1561
|
+
for line in ax.get_lines():
|
1562
|
+
xy = line.get_xydata()
|
1563
|
+
if xy.shape[0] == 0:
|
1564
|
+
continue
|
1565
|
+
|
1566
|
+
dist = np.linalg.norm(xy - np.array([x,y]), axis=1)
|
1567
|
+
idx_min = np.argmin(dist)
|
1568
|
+
if dist[idx_min] < dist_min:
|
1569
|
+
dist_min = dist[idx_min]
|
1570
|
+
line_min = line
|
1571
|
+
|
1572
|
+
self._ax_current.SetSelection(idx)
|
1573
|
+
self._fill_lines_ax(idx = ax.get_lines().index(line_min))
|
1574
|
+
self._axes_properties[idx].select_line(ax.get_lines().index(line_min))
|
1575
|
+
self.fill_grid_with_xy(line_min)
|
1576
|
+
|
1577
|
+
if rclick and self._shiftdown:
|
1578
|
+
xy = self.cur_line.get_xydata()
|
1579
|
+
xy = np.vstack((xy, [x,y]))
|
1580
|
+
self.cur_line.set_data(xy[:,0], xy[:,1])
|
1581
|
+
self.fill_grid_with_xy(self.cur_line)
|
1582
|
+
self._canvas.draw()
|
1551
1583
|
|
1552
1584
|
self.show_curline_properties()
|
1553
1585
|
|
@@ -1609,6 +1641,17 @@ class Matplotlib_Figure(wx.Frame):
|
|
1609
1641
|
xy = self._get_xy_from_grid(self._xls)
|
1610
1642
|
self.add_line(xy, self.cur_ax)
|
1611
1643
|
|
1644
|
+
def onnew_line(self, event):
|
1645
|
+
""" Add a plot to the current ax """
|
1646
|
+
|
1647
|
+
curline = self.cur_line
|
1648
|
+
if curline is not None:
|
1649
|
+
xy = curline.get_xydata()
|
1650
|
+
xy = np.asarray([[xy[0,0],xy[0,1]]])
|
1651
|
+
else:
|
1652
|
+
xy = np.asarray([[0,0]])
|
1653
|
+
self.add_line(xy, self.cur_ax)
|
1654
|
+
|
1612
1655
|
def _get_xy_from_grid(self, grid:CpGrid, colx:int= 0, coly:int= 1):
|
1613
1656
|
""" Get the xy from a grid """
|
1614
1657
|
|
@@ -1637,23 +1680,29 @@ class Matplotlib_Figure(wx.Frame):
|
|
1637
1680
|
cur_ax_prop:Matplotlib_ax_properties = self._axes_properties[idx_ax]
|
1638
1681
|
cur_ax_prop._lines.append(Matplolib_line_properties(ax.get_lines()[-1], cur_ax_prop))
|
1639
1682
|
cur_ax_prop._lines[-1].add_props_to_sizer(self._collaps_pane.GetPane(), self._sizer_grid_props)
|
1683
|
+
|
1684
|
+
self._fill_lines_ax(len(ax.get_lines())-1)
|
1685
|
+
|
1640
1686
|
self.update_layout()
|
1687
|
+
self._canvas.SetFocus()
|
1641
1688
|
|
1642
1689
|
def ondel_line(self, event):
|
1643
1690
|
""" Remove a plot from the current ax """
|
1644
1691
|
|
1692
|
+
if self._line_current.GetSelection() == -1:
|
1693
|
+
return
|
1694
|
+
|
1645
1695
|
dlg = wx.MessageDialog(self, _('Do you want to remove the selected line?\n\nSuch action is irrevocable !\n\nPlease consider to set "Visible" to "False" to hide data'), _('Remove line'), wx.YES_NO | wx.ICON_QUESTION | wx.NO_DEFAULT)
|
1646
1696
|
|
1647
1697
|
ret = dlg.ShowModal()
|
1648
1698
|
if ret == wx.ID_NO:
|
1649
1699
|
return
|
1650
1700
|
|
1651
|
-
if self._line_current.GetSelection() == -1:
|
1652
|
-
return
|
1653
|
-
|
1654
1701
|
idx = self._line_current.GetSelection()
|
1655
1702
|
self.del_line(idx)
|
1656
1703
|
|
1704
|
+
self._fill_lines_ax()
|
1705
|
+
|
1657
1706
|
def del_line(self, idx:int):
|
1658
1707
|
""" Delete a line """
|
1659
1708
|
|
wolfhece/picc.py
CHANGED
@@ -64,10 +64,10 @@ class Picc_data(Element_To_Draw):
|
|
64
64
|
if datafile.exists():
|
65
65
|
self.zones = Zones(data_dir / self._filename_vector, bbox = bbox, mapviewer=self.mapviewer, colors= self._colors)
|
66
66
|
else:
|
67
|
-
logging.
|
67
|
+
logging.info(_('File not found : {}').format(datafile))
|
68
68
|
|
69
69
|
if self.mapviewer is not None:
|
70
|
-
dlg = wx.SingleChoiceDialog(None, _('Would you like to select a
|
70
|
+
dlg = wx.SingleChoiceDialog(None, _('Would you like to select a Shape file or a GDB database ?'), _('Choose data source'), ['Shape file/GPKG', 'GDB database'], wx.CHOICEDLG_STYLE)
|
71
71
|
ret = dlg.ShowModal()
|
72
72
|
|
73
73
|
if ret == wx.ID_CANCEL:
|