wolfhece 2.1.113__py3-none-any.whl → 2.1.115__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 CHANGED
@@ -682,6 +682,8 @@ class DragdropFileTarget(wx.FileDropTarget):
682
682
  else:
683
683
  return False
684
684
 
685
+ pgbar = wx.ProgressDialog(_('Loading files'), _('Loading files'), maximum=len(filenames), parent=self.window, style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE)
686
+
685
687
  for name in filenames:
686
688
 
687
689
  if Path(name).is_dir():
@@ -691,7 +693,7 @@ class DragdropFileTarget(wx.FileDropTarget):
691
693
  continue
692
694
 
693
695
  if test_if_array(name):
694
- ids = self.window.get_list_keys(draw_type.ARRAYS)
696
+ ids = self.window.get_list_keys(draw_type.ARRAYS, checked_state=None)
695
697
  id = Path(name).stem
696
698
  while id in ids:
697
699
  id = id + '_1'
@@ -703,7 +705,7 @@ class DragdropFileTarget(wx.FileDropTarget):
703
705
  logging.error(_('Error while loading array : ') + name)
704
706
 
705
707
  elif test_if_arrayMB(name):
706
- ids = self.window.get_list_keys(draw_type.ARRAYS)
708
+ ids = self.window.get_list_keys(draw_type.ARRAYS, checked_state=None)
707
709
  id = Path(name).stem
708
710
  while id in ids:
709
711
  id = id + '_1'
@@ -715,7 +717,7 @@ class DragdropFileTarget(wx.FileDropTarget):
715
717
  logging.error(_('Error while loading array : ') + name)
716
718
 
717
719
  elif test_if_vector(name):
718
- ids = self.window.get_list_keys(draw_type.VECTORS)
720
+ ids = self.window.get_list_keys(draw_type.VECTORS, checked_state=None)
719
721
  id = Path(name).stem
720
722
  while id in ids:
721
723
  id = id + '_1'
@@ -727,7 +729,7 @@ class DragdropFileTarget(wx.FileDropTarget):
727
729
  logging.error(_('Error while loading vector : ') + name)
728
730
 
729
731
  elif test_if_cloud(name):
730
- ids = self.window.get_list_keys(draw_type.CLOUD)
732
+ ids = self.window.get_list_keys(draw_type.CLOUD, checked_state=None)
731
733
  id = Path(name).stem
732
734
  while id in ids:
733
735
  id = id + '_1'
@@ -738,6 +740,10 @@ class DragdropFileTarget(wx.FileDropTarget):
738
740
  except:
739
741
  logging.error(_('Error while loading cloud : ') + name)
740
742
 
743
+ pgbar.Update(pgbar.GetValue() + 1)
744
+
745
+ pgbar.Destroy()
746
+
741
747
  return True
742
748
 
743
749
 
@@ -1152,6 +1158,10 @@ class WolfMapViewer(wx.Frame):
1152
1158
  active_imagestiles: ImagesTiles
1153
1159
  active_particle_system: Particle_system
1154
1160
  active_viewer3d: Wolf_Viewer3D
1161
+ active_bridges: Bridges
1162
+ active_bridge: Bridge
1163
+ active_weirs : Weirs
1164
+ active_weir : Weir
1155
1165
 
1156
1166
  def __init__(self,
1157
1167
  wxparent = None,
@@ -1245,6 +1255,8 @@ class WolfMapViewer(wx.Frame):
1245
1255
 
1246
1256
  self.menuwolf2d = None
1247
1257
  self.menu_landmap = None
1258
+ self.menu_bridge = None
1259
+ self.menu_weir = None
1248
1260
  self.menu2d_cache_setup = None
1249
1261
  self.menuparticlesystem = None
1250
1262
  self.menu2dGPU = None
@@ -1487,6 +1499,10 @@ class WolfMapViewer(wx.Frame):
1487
1499
  self.active_tile = None
1488
1500
  self.selected_treeitem = None
1489
1501
  self.selected_object = None
1502
+ self.active_bridges = None
1503
+ self.active_bridge = None
1504
+ self.active_weirs = None
1505
+ self.active_weir = None
1490
1506
 
1491
1507
  curtool = self.tools[ID_SORTALONG] = {}
1492
1508
  curtool['menu'] = self.sortalong
@@ -3321,6 +3337,8 @@ class WolfMapViewer(wx.Frame):
3321
3337
  wx.TheClipboard.SetData(dataobj)
3322
3338
  wx.TheClipboard.Close()
3323
3339
 
3340
+ fig.set_visible(False)
3341
+
3324
3342
  buf.close()
3325
3343
 
3326
3344
  return fig, ax, im
@@ -4828,195 +4846,201 @@ class WolfMapViewer(wx.Frame):
4828
4846
  A compléter...
4829
4847
 
4830
4848
  """
4849
+ curdir = Path(os.getcwd())
4850
+
4831
4851
  myproject = Wolf_Param(None, filename=fn, toShow=False)
4832
4852
 
4833
4853
  mykeys = ['cross_sections', 'vector', 'array']
4834
4854
 
4835
- with wx.lib.busy.BusyInfo(_('Opening project')):
4836
- wait = wx.BusyCursor()
4837
- if 'which' in myproject.myparams.keys():
4838
- which = myproject.myparams['which']['action'][key_Param.VALUE]
4839
- if which == 'compare':
4840
- ListCompare = []
4841
- if 'array' in myproject.myparams.keys():
4842
- for curid, curname in zip(myproject.myparams['array'].keys(), myproject.myparams['array'].values()):
4843
- ListCompare.append(WolfArray(normpath(curname[key_Param.VALUE])))
4844
-
4845
- self.set_compare(ListCompare)
4846
- return
4855
+ if 'which' in myproject.myparams.keys():
4856
+ which = myproject.myparams['which']['action'][key_Param.VALUE]
4857
+ if which == 'compare':
4858
+ ListCompare = []
4859
+ if 'array' in myproject.myparams.keys():
4860
+ for curid, curname in zip(myproject.myparams['array'].keys(), myproject.myparams['array'].values()):
4861
+ ListCompare.append(WolfArray(normpath(curname[key_Param.VALUE])))
4847
4862
 
4848
- if 'cross_sections' in myproject.myparams.keys():
4849
- for curid, curname in zip(myproject.myparams['cross_sections'].keys(),
4850
- myproject.myparams['cross_sections'].values()):
4851
- if curid != 'format' and curid != 'dirlaz':
4852
- mycs = crosssections(curname[key_Param.VALUE],
4853
- format=myproject.myparams['cross_sections']['format'][key_Param.VALUE],
4854
- dirlaz=myproject.myparams['cross_sections']['dirlaz'][key_Param.VALUE],
4855
- mapviewer = self)
4863
+ self.set_compare(ListCompare)
4864
+ return
4856
4865
 
4857
- self.add_object('cross_sections', newobj=mycs, id=curid)
4866
+ if 'cross_sections' in myproject.myparams.keys():
4867
+ for curid, curname in zip(myproject.myparams['cross_sections'].keys(),
4868
+ myproject.myparams['cross_sections'].values()):
4869
+ if curid != 'format' and curid != 'dirlaz':
4870
+ mycs = crosssections(curname[key_Param.VALUE],
4871
+ format=myproject.myparams['cross_sections']['format'][key_Param.VALUE],
4872
+ dirlaz=myproject.myparams['cross_sections']['dirlaz'][key_Param.VALUE],
4873
+ mapviewer = self)
4858
4874
 
4875
+ self.add_object('cross_sections', newobj=mycs, id=curid)
4859
4876
 
4860
- if myproject.get_group('tiles') is not None:
4861
4877
 
4862
- curid = myproject.get_param('tiles', 'id')
4863
- curfile = myproject.get_param('tiles', 'tiles_file')
4864
- curdatadir = myproject.get_param('tiles', 'data_dir')
4865
- curcompdir = myproject.get_param('tiles', 'comp_dir')
4878
+ if myproject.get_group('tiles') is not None:
4866
4879
 
4867
- if exists(curfile):
4868
- mytiles = Tiles(filename= curfile, parent=self, linked_data_dir=curdatadir)
4869
- mytiles.set_comp_dir(curcompdir)
4870
- self.add_object('tiles', newobj=mytiles, id=curid)
4871
- else:
4872
- logging.info(_('Bad parameter in project file - tiles : ')+ curfile)
4880
+ curid = myproject.get_param('tiles', 'id')
4881
+ curfile = myproject.get_param('tiles', 'tiles_file')
4882
+ curdatadir = myproject.get_param('tiles', 'data_dir')
4883
+ curcompdir = myproject.get_param('tiles', 'comp_dir')
4873
4884
 
4874
- if myproject.get_group('laz_grid') is not None:
4885
+ if exists(curfile):
4886
+ mytiles = Tiles(filename= curfile, parent=self, linked_data_dir=curdatadir)
4887
+ mytiles.set_comp_dir(curcompdir)
4888
+ self.add_object('tiles', newobj=mytiles, id=curid)
4889
+ else:
4890
+ logging.info(_('Bad parameter in project file - tiles : ')+ curfile)
4875
4891
 
4876
- curdatadir = myproject.get_param('laz_grid', 'data_dir')
4892
+ if myproject.get_group('laz_grid') is not None:
4877
4893
 
4878
- self.init_laz_from_gridinfos(curdatadir)
4894
+ curdatadir = myproject.get_param('laz_grid', 'data_dir')
4879
4895
 
4880
- if 'vector' in myproject.myparams.keys():
4881
- for curid, curname in zip(myproject.myparams['vector'].keys(), myproject.myparams['vector'].values()):
4882
- if exists(curname[key_Param.VALUE]):
4883
- myvec = Zones(curname[key_Param.VALUE], parent=self, mapviewer = self)
4884
- self.add_object('vector', newobj=myvec, id=curid)
4885
- else:
4886
- logging.info(_('Bad parameter in project file - vector : ')+ curname[key_Param.VALUE])
4896
+ self.init_laz_from_gridinfos(curdatadir)
4887
4897
 
4888
- if 'array' in myproject.myparams.keys():
4889
- for curid, curname in zip(myproject.myparams['array'].keys(), myproject.myparams['array'].values()):
4898
+ if 'vector' in myproject.myparams.keys():
4899
+ for curid, curname in zip(myproject.myparams['vector'].keys(), myproject.myparams['vector'].values()):
4900
+ if exists(curname[key_Param.VALUE]):
4901
+ myvec = Zones(curname[key_Param.VALUE], parent=self, mapviewer = self)
4902
+ self.add_object('vector', newobj=myvec, id=curid)
4903
+ else:
4904
+ logging.info(_('Bad parameter in project file - vector : ')+ curname[key_Param.VALUE])
4890
4905
 
4891
- if exists(curname[key_Param.VALUE]):
4892
- curarray = WolfArray(curname[key_Param.VALUE], mapviewer=self)
4893
- self.add_object('array', newobj=curarray, id=curid)
4894
- else:
4895
- logging.info(_('Bad parameter in project file - array : ')+ curname[key_Param.VALUE])
4906
+ if 'array' in myproject.myparams.keys():
4907
+ for curid, curname in zip(myproject.myparams['array'].keys(), myproject.myparams['array'].values()):
4896
4908
 
4897
- if 'cloud' in myproject.myparams.keys():
4898
- for curid, curname in zip(myproject.myparams['cloud'].keys(), myproject.myparams['cloud'].values()):
4899
- if exists(curname[key_Param.VALUE]):
4900
- mycloud = cloud_vertices(curname[key_Param.VALUE], mapviewer=self)
4901
- self.add_object('cloud', newobj=mycloud, id=curid)
4902
- else:
4903
- logging.info(_('Bad parameter in project file - cloud : ')+ curname[key_Param.VALUE])
4904
-
4905
- if 'wolf2d' in myproject.myparams.keys():
4906
- for curid, curname in zip(myproject.myparams['wolf2d'].keys(), myproject.myparams['wolf2d'].values()):
4907
- if exists(curname[key_Param.VALUE]):
4908
- curwolf = Wolfresults_2D(curname[key_Param.VALUE], mapviewer=self)
4909
- self.add_object('res2d', newobj=curwolf, id=curid)
4910
- else:
4911
- logging.info(_('Bad parameter in project file - wolf2d : ')+ curname[key_Param.VALUE])
4909
+ if exists(curname[key_Param.VALUE]):
4910
+ curarray = WolfArray(curname[key_Param.VALUE], mapviewer=self)
4911
+ self.add_object('array', newobj=curarray, id=curid)
4912
+ else:
4913
+ logging.info(_('Bad parameter in project file - array : ')+ curname[key_Param.VALUE])
4912
4914
 
4913
- self.menu_wolf2d()
4915
+ if 'cloud' in myproject.myparams.keys():
4916
+ for curid, curname in zip(myproject.myparams['cloud'].keys(), myproject.myparams['cloud'].values()):
4917
+ if exists(curname[key_Param.VALUE]):
4918
+ mycloud = cloud_vertices(curname[key_Param.VALUE], mapviewer=self)
4919
+ self.add_object('cloud', newobj=mycloud, id=curid)
4920
+ else:
4921
+ logging.info(_('Bad parameter in project file - cloud : ')+ curname[key_Param.VALUE])
4914
4922
 
4915
- if 'gpu2d' in myproject.myparams.keys():
4916
- for curid, curname in zip(myproject.myparams['gpu2d'].keys(), myproject.myparams['gpu2d'].values()):
4917
- if exists(curname[key_Param.VALUE]):
4923
+ if 'wolf2d' in myproject.myparams.keys():
4924
+ for curid, curname in zip(myproject.myparams['wolf2d'].keys(), myproject.myparams['wolf2d'].values()):
4925
+ if exists(curname[key_Param.VALUE]):
4926
+ curwolf = Wolfresults_2D(curname[key_Param.VALUE], mapviewer=self)
4927
+ self.add_object('res2d', newobj=curwolf, id=curid)
4928
+ else:
4929
+ logging.info(_('Bad parameter in project file - wolf2d : ')+ curname[key_Param.VALUE])
4918
4930
 
4919
- if 'simul_gpu_results' in curname[key_Param.VALUE]:
4920
- curwolf = wolfres2DGPU(Path(curname[key_Param.VALUE]), mapviewer=self)
4921
- else:
4922
- if exists(join(curname[key_Param.VALUE], 'simul_gpu_results')):
4923
- curwolf = wolfres2DGPU(Path(join(curname[key_Param.VALUE], 'simul_gpu_results')), mapviewer=self)
4924
- else:
4925
- logging.info(_('Bad directory : ')+ curname[key_Param.VALUE])
4931
+ self.menu_wolf2d()
4926
4932
 
4927
- self.add_object('res2d', newobj=curwolf, id=curid)
4928
- else:
4929
- logging.info(_('Bad directory : ')+ curname[key_Param.VALUE])
4933
+ if 'gpu2d' in myproject.myparams.keys():
4930
4934
 
4931
- self.menu_wolf2d()
4932
- self.menu_2dgpu()
4935
+ pgbar = wx.ProgressDialog(_('Loading GPU results'), _('Loading GPU results'), maximum=len(myproject.myparams['gpu2d'].keys()), parent=self, style=wx.PD_APP_MODAL | wx.PD_AUTO_HIDE)
4933
4936
 
4934
- if 'palette' in myproject.myparams.keys():
4935
- self.project_pal = {}
4936
- for curid, curname in zip(myproject.myparams['palette'].keys(), myproject.myparams['palette'].values()):
4937
- if exists(curname[key_Param.VALUE]):
4938
- mypal = wolfpalette(None, '')
4939
- mypal.readfile(curname[key_Param.VALUE])
4940
- mypal.automatic = False
4937
+ for curid, curname in zip(myproject.myparams['gpu2d'].keys(), myproject.myparams['gpu2d'].values()):
4938
+ if exists(curname[key_Param.VALUE]):
4941
4939
 
4942
- self.project_pal[curid] = mypal
4940
+ if 'simul_gpu_results' in curname[key_Param.VALUE]:
4941
+ curwolf = wolfres2DGPU(curdir / Path(curname[key_Param.VALUE]), mapviewer=self)
4943
4942
  else:
4944
- logging.info(_('Bad parameter in project file - palette : ')+ curname[key_Param.VALUE])
4945
-
4946
- if 'palette-array' in myproject.myparams.keys():
4947
- curarray: WolfArray
4948
- if self.project_pal is not None:
4949
- for curid, curname in zip(myproject.myparams['palette-array'].keys(),
4950
- myproject.myparams['palette-array'].values()):
4951
- if curname[key_Param.VALUE] in self.project_pal.keys():
4952
- curarray = self.getobj_from_id(curid)
4953
- if curarray is not None:
4954
- mypal:wolfpalette
4955
- mypal = self.project_pal[curname[key_Param.VALUE]]
4956
- curarray.mypal = mypal
4957
- if mypal.automatic:
4958
- curarray.myops.palauto.SetValue(1)
4959
- else:
4960
- curarray.myops.palauto.SetValue(0)
4961
- curarray.updatepalette(0)
4962
- curarray.delete_lists()
4963
- else:
4964
- logging.warning(_('Bad parameter in project file - palette-array : ')+ curid)
4965
-
4966
- if 'cross_sections_link' in myproject.myparams.keys():
4967
- if 'linkzones' in myproject.myparams['cross_sections_link'].keys():
4968
- idx = myproject.myparams['cross_sections_link']['linkzones'][key_Param.VALUE]
4943
+ if exists(join(curname[key_Param.VALUE], 'simul_gpu_results')):
4944
+ curwolf = wolfres2DGPU(curdir / Path(join(curname[key_Param.VALUE], 'simul_gpu_results')), mapviewer=self)
4945
+ else:
4946
+ logging.info(_('Bad directory : ')+ curname[key_Param.VALUE])
4969
4947
 
4970
- for curzones in self.iterator_over_objects(draw_type.VECTORS):
4971
- curzones: Zones
4972
- if curzones.idx == idx:
4973
- self.active_cs.link_external_zones(curzones)
4948
+ self.add_object('res2d', newobj=curwolf, id=curid)
4949
+ else:
4950
+ logging.info(_('Bad directory : ')+ curname[key_Param.VALUE])
4974
4951
 
4975
- zonename = ''
4976
- vecname = ''
4952
+ pgbar.Update(pgbar.GetValue() + 1)
4977
4953
 
4978
- if 'sortzone' in myproject.myparams['cross_sections_link'].keys():
4979
- zonename = myproject.myparams['cross_sections_link']['sortzone'][key_Param.VALUE]
4980
- if 'sortname' in myproject.myparams['cross_sections_link'].keys():
4981
- vecname = myproject.myparams['cross_sections_link']['sortname'][key_Param.VALUE]
4954
+ pgbar.Destroy()
4982
4955
 
4983
- if zonename != '' and vecname != '':
4984
- names = [cur.myname for cur in curzones.myzones]
4985
- idx = names.index(zonename)
4986
- curzone = curzones.myzones[idx]
4987
- names = [cur.myname for cur in curzone.myvectors]
4988
- idx = names.index(vecname)
4989
- curvec = curzone.myvectors[idx]
4956
+ self.menu_wolf2d()
4957
+ self.menu_2dgpu()
4990
4958
 
4991
- if curvec is not None:
4992
- curvec: vector
4993
- self.active_cs.sort_along(curvec.asshapely_ls(), curvec.myname, False)
4959
+ if 'palette' in myproject.myparams.keys():
4960
+ self.project_pal = {}
4961
+ for curid, curname in zip(myproject.myparams['palette'].keys(), myproject.myparams['palette'].values()):
4962
+ if exists(curname[key_Param.VALUE]):
4963
+ mypal = wolfpalette(None, '')
4964
+ mypal.readfile(curname[key_Param.VALUE])
4965
+ mypal.automatic = False
4994
4966
 
4995
- if 'vector_array_link' in myproject.myparams.keys():
4996
- for curid, curname in zip(myproject.myparams['vector_array_link'].keys(), myproject.myparams['vector_array_link'].values()):
4967
+ self.project_pal[curid] = mypal
4968
+ else:
4969
+ logging.info(_('Bad parameter in project file - palette : ')+ curname[key_Param.VALUE])
4997
4970
 
4998
- locvec = None
4999
- locarray = None
5000
- for curvec in self.myvectors:
5001
- if curvec.idx == curname[key_Param.VALUE].lower():
5002
- locvec=curvec
5003
- break
4971
+ if 'palette-array' in myproject.myparams.keys():
4972
+ curarray: WolfArray
4973
+ if self.project_pal is not None:
4974
+ for curid, curname in zip(myproject.myparams['palette-array'].keys(),
4975
+ myproject.myparams['palette-array'].values()):
4976
+ if curname[key_Param.VALUE] in self.project_pal.keys():
4977
+ curarray = self.getobj_from_id(curid)
4978
+ if curarray is not None:
4979
+ mypal:wolfpalette
4980
+ mypal = self.project_pal[curname[key_Param.VALUE]]
4981
+ curarray.mypal = mypal
4982
+ if mypal.automatic:
4983
+ curarray.myops.palauto.SetValue(1)
4984
+ else:
4985
+ curarray.myops.palauto.SetValue(0)
4986
+ curarray.updatepalette(0)
4987
+ curarray.delete_lists()
4988
+ else:
4989
+ logging.warning(_('Bad parameter in project file - palette-array : ')+ curid)
4990
+
4991
+ if 'cross_sections_link' in myproject.myparams.keys():
4992
+ if 'linkzones' in myproject.myparams['cross_sections_link'].keys():
4993
+ idx = myproject.myparams['cross_sections_link']['linkzones'][key_Param.VALUE]
4994
+
4995
+ for curzones in self.iterator_over_objects(draw_type.VECTORS):
4996
+ curzones: Zones
4997
+ if curzones.idx == idx:
4998
+ self.active_cs.link_external_zones(curzones)
4999
+
5000
+ zonename = ''
5001
+ vecname = ''
5002
+
5003
+ if 'sortzone' in myproject.myparams['cross_sections_link'].keys():
5004
+ zonename = myproject.myparams['cross_sections_link']['sortzone'][key_Param.VALUE]
5005
+ if 'sortname' in myproject.myparams['cross_sections_link'].keys():
5006
+ vecname = myproject.myparams['cross_sections_link']['sortname'][key_Param.VALUE]
5007
+
5008
+ if zonename != '' and vecname != '':
5009
+ names = [cur.myname for cur in curzones.myzones]
5010
+ idx = names.index(zonename)
5011
+ curzone = curzones.myzones[idx]
5012
+ names = [cur.myname for cur in curzone.myvectors]
5013
+ idx = names.index(vecname)
5014
+ curvec = curzone.myvectors[idx]
5015
+
5016
+ if curvec is not None:
5017
+ curvec: vector
5018
+ self.active_cs.sort_along(curvec.asshapely_ls(), curvec.myname, False)
5019
+
5020
+ if 'vector_array_link' in myproject.myparams.keys():
5021
+ for curid, curname in zip(myproject.myparams['vector_array_link'].keys(), myproject.myparams['vector_array_link'].values()):
5022
+
5023
+ locvec = None
5024
+ locarray = None
5025
+ for curvec in self.myvectors:
5026
+ if curvec.idx == curname[key_Param.VALUE].lower():
5027
+ locvec=curvec
5028
+ break
5004
5029
 
5005
- for curarray in self.myarrays:
5006
- if curarray.idx == curid.lower():
5007
- locarray=curarray
5008
- break
5030
+ for curarray in self.myarrays:
5031
+ if curarray.idx == curid.lower():
5032
+ locarray=curarray
5033
+ break
5009
5034
 
5010
- if locvec is not None and locarray is not None:
5035
+ if locvec is not None and locarray is not None:
5011
5036
 
5012
- locarray.linkedvec = locvec.myzones[0].myvectors[0]
5037
+ locarray.linkedvec = locvec.myzones[0].myvectors[0]
5013
5038
 
5014
- else:
5039
+ else:
5015
5040
 
5016
- logging.warning(_('Bad vec-array association in project file !'))
5017
- logging.warning(curid)
5018
- logging.warning(curname[key_Param.VALUE])
5019
- del wait
5041
+ logging.warning(_('Bad vec-array association in project file !'))
5042
+ logging.warning(curid)
5043
+ logging.warning(curname[key_Param.VALUE])
5020
5044
 
5021
5045
  def save_project(self, fn):
5022
5046
  myproject = Wolf_Param(None, toShow=False)
@@ -5765,8 +5789,10 @@ class WolfMapViewer(wx.Frame):
5765
5789
  filename = file.GetPath()
5766
5790
  file.Destroy()
5767
5791
 
5792
+ old_dir = os.getcwd()
5768
5793
  os.chdir(os.path.dirname(filename))
5769
5794
  self.read_project(filename)
5795
+ os.chdir(old_dir)
5770
5796
 
5771
5797
  elif itemlabel == _('Shortcuts'):
5772
5798
  # show shortcuts in log
@@ -7581,7 +7607,7 @@ class WolfMapViewer(wx.Frame):
7581
7607
  filterjson = "json (*.json)|*.json|all (*.*)|*.*"
7582
7608
  filterall = "all (*.*)|*.*"
7583
7609
  filterres2d = "all (*.*)|*.*"
7584
- filterVector = "vec (*.vec)|*.vec|vecz (*.vecz)|*.vecz|dxf (*.dxf)|*.dxf|shp (*.shp)|*.shp|all (*.*)|*.*"
7610
+ filterVector = "All supported formats|*.vec;*.vecz;*.dxf;*.shp|vec (*.vec)|*.vec|vecz (*.vecz)|*.vecz|dxf (*.dxf)|*.dxf|shp (*.shp)|*.shp|all (*.*)|*.*"
7585
7611
  filterCloud = "xyz (*.xyz)|*.xyz|dxf (*.dxf)|*.dxf|text (*.txt)|*.txt|shp (*.shp)|*.shp|all (*.*)|*.*"
7586
7612
  filtertri = "tri (*.tri)|*.tri|text (*.txt)|*.txt|dxf (*.dxf)|*.dxf|gltf (*.gltf)|*.gltf|gltf binary (*.glb)|*.glb|*.*'all (*.*)|*.*"
7587
7613
  filterCs = "vecz WOLF (*.vecz)|*.vecz|txt 2022 (*.txt)|*.txt|WOLF (*.sxy)|*.sxy|text 2000 (*.txt)|*.txt|all (*.*)|*.*"
@@ -7824,8 +7850,13 @@ class WolfMapViewer(wx.Frame):
7824
7850
  wait = wx.BusyCursor()
7825
7851
  newobj = Bridges(filename, mapviewer=self)
7826
7852
  del wait
7853
+
7827
7854
  self.myvectors.append(newobj)
7828
7855
 
7856
+ self.active_bridges = newobj
7857
+
7858
+ self.menu_bridges()
7859
+
7829
7860
  elif which.lower() == 'weirs':
7830
7861
  curdict = self.myvectors
7831
7862
  curtree = self.myitemsvector
@@ -7837,6 +7868,10 @@ class WolfMapViewer(wx.Frame):
7837
7868
  del wait
7838
7869
  self.myvectors.append(newobj)
7839
7870
 
7871
+ self.active_weirs = newobj
7872
+
7873
+ self.menu_weirs()
7874
+
7840
7875
  elif which.lower() in ['tiles', 'tilescomp']:
7841
7876
  curdict = self.mytiles
7842
7877
  curtree = self.myitemsvector
@@ -8622,6 +8657,8 @@ class WolfMapViewer(wx.Frame):
8622
8657
  self.selected_object.write_all()
8623
8658
  elif type(self.selected_object) is Zones:
8624
8659
  self.selected_object.saveas()
8660
+ elif type(self.selected_object) in [Bridge, Weir]:
8661
+ self.selected_object.saveas()
8625
8662
  elif type(self.selected_object) is Triangulation:
8626
8663
  self.selected_object.saveas()
8627
8664
  elif isinstance(self.selected_object, Particle_system):
@@ -8742,7 +8779,7 @@ class WolfMapViewer(wx.Frame):
8742
8779
 
8743
8780
  self.selected_object.write_all()
8744
8781
  fdlg.Destroy()
8745
- elif type(self.selected_object) is Zones:
8782
+ elif type(self.selected_object) in [Zones, Bridge, Weir]:
8746
8783
  filterArray = "vec (*.vec)|*.vec|vecz (*.vecz)|*.vecz|Shapefile (*.shp)|*.shp|all (*.*)|*.*"
8747
8784
  fdlg = wx.FileDialog(self, "Choose file name for Vector :" + self.selected_object.idx, wildcard=filterArray,
8748
8785
  style=wx.FD_SAVE)
@@ -8772,8 +8809,9 @@ class WolfMapViewer(wx.Frame):
8772
8809
  elif text == _('Properties'):
8773
8810
 
8774
8811
  myobj = self.selected_object
8775
- if type(myobj) in [WolfArray, WolfArrayMB, WolfArrayMNAP, Zones, Wolfresults_2D, wolfres2DGPU, Particle_system, Picc_data, Cadaster_data, hydrometry_wolfgui]:
8812
+ if type(myobj) in [WolfArray, WolfArrayMB, WolfArrayMNAP, Zones, Wolfresults_2D, wolfres2DGPU, Particle_system, Picc_data, Cadaster_data, hydrometry_wolfgui, Bridge, Weir]:
8776
8813
  myobj.show_properties()
8814
+
8777
8815
  elif isinstance(myobj, cloud_vertices):
8778
8816
  myobj.show_properties()
8779
8817
 
@@ -8856,7 +8894,7 @@ class WolfMapViewer(wx.Frame):
8856
8894
 
8857
8895
  elif _('Export to Shape file') in text:
8858
8896
 
8859
- if isinstance(self.selected_object, Zones):
8897
+ if isinstance(self.selected_object, Zones | Bridge | Weir):
8860
8898
  filterArray = "Shapefile (*.shp)|*.shp"
8861
8899
  fdlg = wx.FileDialog(self, "Choose file name for Zones :" + self.selected_object.idx, wildcard=filterArray,
8862
8900
  style=wx.FD_SAVE)
@@ -8867,7 +8905,7 @@ class WolfMapViewer(wx.Frame):
8867
8905
 
8868
8906
  elif _('Export active zone to Shape file') in text:
8869
8907
 
8870
- if isinstance(self.selected_object, Zones):
8908
+ if isinstance(self.selected_object, Zones | Bridge | Weir):
8871
8909
 
8872
8910
  filterArray = "Shapefile (*.shp)|*.shp"
8873
8911
  fdlg = wx.FileDialog(self, "Choose file name for Vector :" + self.selected_object.idx, wildcard=filterArray,
@@ -9094,12 +9132,12 @@ class WolfMapViewer(wx.Frame):
9094
9132
  logging.warning(_('No triangles selected -- Please select a triangulation first !'))
9095
9133
  return
9096
9134
 
9097
- if self.active_tri._start_move is None:
9098
- self.active_tri._start_move = (x, y)
9135
+ if self.active_tri._move_start is None:
9136
+ self.active_tri._move_start = (x, y)
9099
9137
  return
9100
9138
 
9101
- delta_x = x - self.active_tri._start_move[0]
9102
- delta_y = y - self.active_tri._start_move[1]
9139
+ delta_x = x - self.active_tri._move_start[0]
9140
+ delta_y = y - self.active_tri._move_start[1]
9103
9141
 
9104
9142
  if shiftdown:
9105
9143
  delta_y = 0.
@@ -9109,7 +9147,7 @@ class WolfMapViewer(wx.Frame):
9109
9147
 
9110
9148
  self.active_tri.move(delta_x, delta_y)
9111
9149
  self.active_tri.reset_plot()
9112
- self.active_tri._start_move = None
9150
+ self.active_tri._move_start = None
9113
9151
  self.active_tri.clear_cache()
9114
9152
  self.end_action(_('End move triangulation'))
9115
9153
 
@@ -9149,6 +9187,12 @@ class WolfMapViewer(wx.Frame):
9149
9187
  self.active_landmap.load_texture(x,y, which='low')
9150
9188
  self.Refresh()
9151
9189
 
9190
+ elif self.action == 'pick bridge':
9191
+ self.pick_bridge(x, y)
9192
+
9193
+ elif self.action == 'pick weir':
9194
+ self.pick_weir(x, y)
9195
+
9152
9196
  elif self.action == 'bridge gltf':
9153
9197
  # Create a bridge in gltf format
9154
9198
 
@@ -9356,12 +9400,12 @@ class WolfMapViewer(wx.Frame):
9356
9400
  logging.warning(_('No vector selected -- Please select a vector first !'))
9357
9401
  return
9358
9402
 
9359
- if self.active_vector._start_move is None:
9360
- self.active_vector._start_move = (x, y)
9403
+ if self.active_vector._move_start is None:
9404
+ self.active_vector._move_start = (x, y)
9361
9405
  return
9362
9406
 
9363
- delta_x = x - self.active_vector._start_move[0]
9364
- delta_y = y - self.active_vector._start_move[1]
9407
+ delta_x = x - self.active_vector._move_start[0]
9408
+ delta_y = y - self.active_vector._move_start[1]
9365
9409
 
9366
9410
  if shiftdown:
9367
9411
  delta_y = 0.
@@ -9400,8 +9444,8 @@ class WolfMapViewer(wx.Frame):
9400
9444
  logging.warning(_('No zone selected -- Please select a zone first !'))
9401
9445
  return
9402
9446
 
9403
- if self.active_zone._start_move is None:
9404
- self.active_zone._start_move = (x, y)
9447
+ if self.active_zone._move_start is None:
9448
+ self.active_zone._move_start = (x, y)
9405
9449
  return
9406
9450
 
9407
9451
  if shiftdown:
@@ -9410,7 +9454,7 @@ class WolfMapViewer(wx.Frame):
9410
9454
  if alt:
9411
9455
  delta_x = 0.
9412
9456
 
9413
- self.active_zone.move(x - self.active_zone._start_move[0], y - self.active_zone._start_move[1])
9457
+ self.active_zone.move(x - self.active_zone._move_start[0], y - self.active_zone._move_start[1])
9414
9458
  self.active_zone.clear_cache()
9415
9459
  self.end_action(_('End move zone'))
9416
9460
 
@@ -9657,6 +9701,18 @@ class WolfMapViewer(wx.Frame):
9657
9701
  if ctrl:
9658
9702
  myobj.show_properties()
9659
9703
 
9704
+ elif type(myobj) == Bridge:
9705
+ self.active_bridge = myobj
9706
+
9707
+ if ctrl:
9708
+ myobj.show_properties()
9709
+
9710
+ elif type(myobj) == Weir:
9711
+ self.active_weir = myobj
9712
+
9713
+ if ctrl:
9714
+ myobj.show_properties()
9715
+
9660
9716
  elif isinstance(myobj, PlansTerrier):
9661
9717
  self.active_landmap = myobj
9662
9718
 
@@ -10131,10 +10187,10 @@ class WolfMapViewer(wx.Frame):
10131
10187
 
10132
10188
  if self.action == 'move vector':
10133
10189
  if self.active_vector is not None:
10134
- if self.active_vector._start_move is not None:
10190
+ if self.active_vector._move_start is not None:
10135
10191
 
10136
- delta_x = x - self.active_vector._start_move[0]
10137
- delta_y = y - self.active_vector._start_move[1]
10192
+ delta_x = x - self.active_vector._move_start[0]
10193
+ delta_y = y - self.active_vector._move_start[1]
10138
10194
 
10139
10195
  if shiftdown:
10140
10196
  delta_y = 0.
@@ -10146,10 +10202,10 @@ class WolfMapViewer(wx.Frame):
10146
10202
 
10147
10203
  if self.action == 'move triangles':
10148
10204
  if self.active_tri is not None:
10149
- if self.active_tri._start_move is not None:
10205
+ if self.active_tri._move_start is not None:
10150
10206
 
10151
- delta_x = x - self.active_tri._start_move[0]
10152
- delta_y = y - self.active_tri._start_move[1]
10207
+ delta_x = x - self.active_tri._move_start[0]
10208
+ delta_y = y - self.active_tri._move_start[1]
10153
10209
 
10154
10210
  if shiftdown:
10155
10211
  delta_y = 0.
@@ -10174,9 +10230,9 @@ class WolfMapViewer(wx.Frame):
10174
10230
 
10175
10231
  if self.action == 'move zone':
10176
10232
  if self.active_zone is not None:
10177
- if self.active_zone._start_move is not None:
10178
- delta_x = x - self.active_zone._start_move[0]
10179
- delta_y = y - self.active_zone._start_move[1]
10233
+ if self.active_zone._move_start is not None:
10234
+ delta_x = x - self.active_zone._move_start[0]
10235
+ delta_y = y - self.active_zone._move_start[1]
10180
10236
 
10181
10237
  if shiftdown:
10182
10238
  delta_y = 0.
@@ -10827,7 +10883,7 @@ class WolfMapViewer(wx.Frame):
10827
10883
  newarray.nullify_border(width=1)
10828
10884
 
10829
10885
  #keys for arrays
10830
- keys = self.get_list_keys(draw_type.ARRAYS, checked_state=False)
10886
+ keys = self.get_list_keys(draw_type.ARRAYS, checked_state=None)
10831
10887
  new_key = self.active_array.idx + '_crop'
10832
10888
 
10833
10889
  while new_key in keys:
@@ -11355,7 +11411,7 @@ class WolfMapViewer(wx.Frame):
11355
11411
  self.popupmenu.Append(wx.ID_ANY, _('Convert to mono-block (result)'), _('Convert to mono-block'))
11356
11412
  self.popupmenu.Append(wx.ID_ANY, _('Convert to multi-blocks (result)'), _('Convert to multi-blocks'))
11357
11413
 
11358
- if isinstance(self.selected_object, Zones):
11414
+ if isinstance(self.selected_object, Zones | Bridge | Weir):
11359
11415
  self.popupmenu.Append(wx.ID_ANY, _('Export to Shape file'), _('Export to Shape file'))
11360
11416
  self.popupmenu.Append(wx.ID_ANY, _('Export active zone to Shape file'), _('Export active zone to Shape file'))
11361
11417
 
@@ -11808,6 +11864,117 @@ class WolfMapViewer(wx.Frame):
11808
11864
  self.zoom_on(zoom)
11809
11865
 
11810
11866
 
11867
+ def menu_bridges(self):
11868
+
11869
+ if self.menu_bridge is None:
11870
+ self.menu_bridge = wx.Menu()
11871
+ self.menubar.Append(self.menu_bridge, _('&Bridges'))
11872
+
11873
+ self._menu_add_bridge = self.menu_bridge.Append(wx.ID_ANY, _('New bridge'), _('Add a new bridge to the active collection...'))
11874
+ self._menu_find_bridge = self.menu_bridge.Append(wx.ID_ANY, _('Pick bridge'), _("Pick the mouse's nearest bridge"))
11875
+ self._menu_edit_bridge = self.menu_bridge.Append(wx.ID_ANY, _('Edit bridge'), _('Edit the active bridge'))
11876
+
11877
+ self.Bind(wx.EVT_MENU, self.OnAddBridge, self._menu_add_bridge)
11878
+ self.Bind(wx.EVT_MENU, self.OnEditBridge, self._menu_edit_bridge)
11879
+ self.Bind(wx.EVT_MENU, self.OnFindBridge, self._menu_find_bridge)
11880
+
11881
+ def OnAddBridge(self, e):
11882
+ """ Add a bridge """
11883
+
11884
+ if self.active_bridges is None:
11885
+ logging.warning(_('No bridge collection !'))
11886
+ return
11887
+
11888
+ newid = wx.TextEntryDialog(None, _('Enter the new bridge id'), _('New bridge id'), 'bridge')
11889
+ if newid.ShowModal() == wx.ID_OK:
11890
+
11891
+ newid = newid.GetValue()
11892
+ while newid in self.get_list_keys(drawing_type=draw_type.VECTORS):
11893
+ newid = newid + '_'
11894
+
11895
+ newbridge = self.active_bridges.addnew(newid)
11896
+ self.add_object('vector', newobj=newbridge, id=newid)
11897
+
11898
+ def OnEditBridge(self, e):
11899
+ """ Edit a bridge """
11900
+
11901
+ if self.active_bridge is None:
11902
+ logging.warning(_('No active bridge to edit !'))
11903
+ return
11904
+
11905
+ keys = self.get_list_keys(drawing_type=draw_type.VECTORS)
11906
+
11907
+ newid = self.active_bridge.idx
11908
+ while newid in keys:
11909
+ newid = newid + '_'
11910
+
11911
+ self.add_object('vector', newobj=self.active_bridge, id= newid)
11912
+
11913
+ def OnFindBridge(self, e):
11914
+ """ Find the nearest bridge """
11915
+
11916
+ self.start_action('Pick bridge', _('Right click to pick the nearest bridge'))
11917
+
11918
+ def pick_bridge(self, x:float, y:float):
11919
+ """ Find the nearest bridge """
11920
+
11921
+ if self.active_bridges is None:
11922
+ logging.warning(_('No bridges to pick !'))
11923
+ return
11924
+
11925
+ self.active_bridge = self.active_bridges.find_nearest(x,y)
11926
+
11927
+ def menu_weirs(self):
11928
+
11929
+ if self.menu_weir is None:
11930
+ self.menu_weir = wx.Menu()
11931
+ self.menubar.Append(self.menu_weir, _('&Weirs'))
11932
+
11933
+ self._menu_add_weir = self.menu_weir.Append(wx.ID_ANY, _('New weir'), _('Add a new weir to the active collection'))
11934
+ self._menu_find_weir = self.menu_weir.Append(wx.ID_ANY, _('Pick weir'), _("Pick the mouse's nearest weir"))
11935
+ self._menu_edit_weir = self.menu_weir.Append(wx.ID_ANY, _('Edit weir'), _('Edit the active weir'))
11936
+
11937
+ self.Bind(wx.EVT_MENU, self.OnAddWeir, self._menu_add_weir)
11938
+ self.Bind(wx.EVT_MENU, self.OnEditWeir, self._menu_edit_weir)
11939
+ self.Bind(wx.EVT_MENU, self.OnFindWeir, self._menu_find_weir)
11940
+
11941
+ def OnAddWeir(self, e):
11942
+ """ Add a weir """
11943
+
11944
+ logging.info(_('!! To be implemented !!'))
11945
+ pass
11946
+
11947
+ def OnEditWeir(self, e):
11948
+ """ Edit a weir """
11949
+
11950
+ if self.active_weir is None:
11951
+ logging.warning(_('No active weir to edit !'))
11952
+ return
11953
+
11954
+ keys = self.get_list_keys(drawing_type=draw_type.VECTORS)
11955
+
11956
+ newid = self.active_weir.idx
11957
+ while newid in keys:
11958
+ newid = newid + '_'
11959
+
11960
+ self.add_object('vector', newobj=self.active_weir, id= newid)
11961
+
11962
+ def OnFindWeir(self, e):
11963
+ """ Find the nearest weir """
11964
+
11965
+ self.start_action('Pick weir', _('Right click to pick the nearest weir'))
11966
+
11967
+ def pick_weir(self, x:float, y:float):
11968
+ """ Find the nearest weir """
11969
+
11970
+ if self.active_weirs is None:
11971
+ logging.warning(_('No weirs to pick !'))
11972
+ return
11973
+
11974
+ self.active_weir = self.active_weirs.find_nearest(x,y)
11975
+
11976
+
11977
+
11811
11978
  class Comp_Type(Enum):
11812
11979
  ARRAYS = 1
11813
11980
  ARRAYS_MB = 2
@@ -11852,6 +12019,21 @@ class Compare_Arrays_Results():
11852
12019
 
11853
12020
  return Comp_Type.RES2D, file
11854
12021
 
12022
+ elif file.suffix in ('.bin', '.tif', '.tiff', '.npy', '.npz', '.top', '.frott', '.nap', '.hbin', '.hbinb', '.qxbin', '.qxbinb', '.qybin', '.qybinb', '.inf') :
12023
+
12024
+ if file.suffix in ('.bin', '.top', '.frott', '.nap', '.hbin', '.hbinb', '.qxbin', '.qxbinb', '.qybin', '.qybinb', '.inf'):
12025
+ if file.with_suffix(file.suffix + '.txt').exists():
12026
+
12027
+ test = WolfArray(file, preload=False)
12028
+ test.read_txt_header()
12029
+
12030
+ mb = test.nb_blocks > 0
12031
+
12032
+ if mb:
12033
+ return Comp_Type.ARRAYS_MB, file
12034
+
12035
+ return Comp_Type.ARRAYS, file
12036
+
11855
12037
  elif (file.parent / 'simul_gpu_results').exists():
11856
12038
  file = file.parent / 'simul_gpu_results'
11857
12039
  return Comp_Type.RES2D_GPU, file
@@ -11859,24 +12041,8 @@ class Compare_Arrays_Results():
11859
12041
  elif (file.parent.parent / 'simul_gpu_results').exists():
11860
12042
  file = file.parent.parent / 'simul_gpu_results'
11861
12043
  return Comp_Type.RES2D_GPU, file
11862
-
11863
12044
  else:
11864
- if file.suffix in ('.bin', '.tif', '.tiff', '.npy', '.npz', '.top', '.frott', '.nap', '.hbin', '.hbinb', '.qxbin', '.qxbinb', '.qybin', '.qybinb', '.inf') :
11865
-
11866
- if file.suffix in ('.bin', '.top', '.frott', '.nap', '.hbin', '.hbinb', '.qxbin', '.qxbinb', '.qybin', '.qybinb', '.inf'):
11867
- if file.with_suffix(file.suffix + '.txt').exists():
11868
-
11869
- test = WolfArray(file, preload=False)
11870
- test.read_txt_header()
11871
-
11872
- mb = test.nb_blocks > 0
11873
-
11874
- if mb:
11875
- return Comp_Type.ARRAYS_MB, file
11876
-
11877
- return Comp_Type.ARRAYS, file
11878
- else:
11879
- return None, None
12045
+ return None, None
11880
12046
 
11881
12047
  def add(self, file_or_dir:Union[str, Path] = None):
11882
12048