wolfhece 2.1.120__py3-none-any.whl → 2.1.122__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
@@ -3451,14 +3451,16 @@ class WolfMapViewer(wx.Frame):
3451
3451
  # self.active_tri = mytri
3452
3452
 
3453
3453
  def triangulate_cs(self):
3454
+ """ Triangulate the active cross sections """
3454
3455
 
3455
3456
  msg = ''
3456
3457
  if self.active_zones is None:
3457
3458
  msg += _(' The active zones is None. Please activate the desired object !\n')
3458
3459
  if self.active_cs is None:
3459
- msg += _(' The is no cross section. Please active the desired object or load file!')
3460
+ msg += _(' The is no cross section. Please active the desired object or load file !')
3460
3461
 
3461
3462
  if msg != '':
3463
+ logging.warning(msg)
3462
3464
  dlg = wx.MessageBox(msg, 'Required action')
3463
3465
  return
3464
3466
 
@@ -3471,9 +3473,17 @@ class WolfMapViewer(wx.Frame):
3471
3473
  ds = float(dlg.GetValue()) / 100.
3472
3474
  dlg.Destroy()
3473
3475
 
3474
- self.myinterp = Interpolators(self.active_zones, self.active_cs, ds)
3476
+ self.set_interp_cs(Interpolators(self.active_zones, self.active_cs, ds))
3475
3477
 
3476
- self.add_object('vector', newobj=self.myinterp.myzones, ToCheck=False, id='Interp_mesh')
3478
+ def set_interp_cs(self, obj:Interpolators, add_zones:bool = True):
3479
+ """ Set the active cross-sections interpolator """
3480
+
3481
+ assert isinstance(obj, Interpolators), _('Please provide an Interpolators object')
3482
+
3483
+ self.myinterp = obj
3484
+
3485
+ if add_zones:
3486
+ self.add_object('vector', newobj=self.myinterp.myzones, ToCheck=False, id='Interp_mesh')
3477
3487
 
3478
3488
  if self.menuviewerinterpcs is None:
3479
3489
  self.menuviewerinterpcs = self.cs_menu.Append(wx.ID_ANY, _("New cloud Viewer..."),
@@ -3481,6 +3491,8 @@ class WolfMapViewer(wx.Frame):
3481
3491
  if self.menuinterpcs is None:
3482
3492
  self.menuinterpcs = self.cs_menu.Append(wx.ID_ANY, _("Interpolate on active array..."), _("Interpolate"))
3483
3493
 
3494
+ self.Refresh()
3495
+
3484
3496
  def interpolate_cloud(self):
3485
3497
  """
3486
3498
  Interpolation d'un nuage de point sur une matrice
@@ -3514,25 +3526,39 @@ class WolfMapViewer(wx.Frame):
3514
3526
  self.active_cloud.interp_on_array(self.active_array,keyvalue,method)
3515
3527
 
3516
3528
  def interpolate_cs(self):
3517
- if self.active_array is not None and self.myinterp is not None:
3529
+ """ Interpolate the active cross sections by interpolators """
3518
3530
 
3519
- choices = ["nearest", "linear", "cubic"]
3520
- dlg = wx.SingleChoiceDialog(None, "Pick an interpolate method", "Choices", choices)
3521
- ret = dlg.ShowModal()
3522
- if ret == wx.ID_CANCEL:
3523
- dlg.Destroy()
3524
- return
3531
+ if self.active_array is None:
3532
+ logging.warning(_('No active array -- Please activate an array first'))
3533
+ return
3525
3534
 
3526
- method = dlg.GetStringSelection()
3535
+ if self.myinterp is None:
3536
+ logging.warning(_('No active interpolator -- Please create an interpolator first'))
3537
+ return
3538
+
3539
+ choices = ["nearest", "linear", "cubic"]
3540
+ dlg = wx.SingleChoiceDialog(None, "Pick an interpolate method", "Choices", choices)
3541
+ ret = dlg.ShowModal()
3542
+ if ret == wx.ID_CANCEL:
3527
3543
  dlg.Destroy()
3544
+ return
3545
+
3546
+ method = dlg.GetStringSelection()
3547
+ dlg.Destroy()
3528
3548
 
3529
- self.myinterp.interp_on_array(self.active_array, method)
3549
+ self.myinterp.interp_on_array(self.active_array, method)
3530
3550
 
3531
3551
  def interpolate_triangulation(self):
3532
3552
 
3533
- if self.active_array is not None and self.active_tri is not None:
3553
+ if self.active_array is None:
3554
+ logging.warning(_('No active array -- Please activate an array first'))
3555
+ return
3534
3556
 
3535
- self.active_array.interpolate_on_triangulation(self.active_tri.pts, self.active_tri.tri, )
3557
+ if self.active_tri is None:
3558
+ logging.warning(_('No active triangulation -- Please activate a triangulation first'))
3559
+ return
3560
+
3561
+ self.active_array.interpolate_on_triangulation(self.active_tri.pts, self.active_tri.tri, )
3536
3562
 
3537
3563
  def compare_cloud2array(self):
3538
3564
  """
@@ -5338,7 +5364,7 @@ class WolfMapViewer(wx.Frame):
5338
5364
  if myproject.is_in(curgroup):
5339
5365
  if check_params(myproject, curgroup):
5340
5366
  try:
5341
- self.init_laz_from_gridinfos(myproject[curgroup, 'data_dir'], myproject[(curgroup, 'classification')])
5367
+ self.init_laz_from_gridinfos(curdir / myproject[curgroup, 'data_dir'], myproject[(curgroup, 'classification')])
5342
5368
  except Exception as e:
5343
5369
  logging.error(_('Error in laz_grid import : ')+ str(e))
5344
5370
  else:
@@ -5873,7 +5899,7 @@ class WolfMapViewer(wx.Frame):
5873
5899
 
5874
5900
  logging.info(_('Clip LAZ grid on current zoom'))
5875
5901
  logging.info(_('Bounds {}-{} {}-{}').format(curbounds[0][0],curbounds[0][1],curbounds[1][0],curbounds[1][1]))
5876
- logging.info(_('Nb points : {}').format(self.active_laz.num_points))
5902
+ logging.info(_('Nb points : {:_}').format(self.active_laz.num_points))
5877
5903
 
5878
5904
  def filter_active_laz(self):
5879
5905
  """ Filter active laz data """
@@ -5892,7 +5918,7 @@ class WolfMapViewer(wx.Frame):
5892
5918
  used_codes = [codes[cur] for cur in used_codes]
5893
5919
  self.active_laz.filter_data(used_codes)
5894
5920
 
5895
- logging.info(_('Filter done - Nb points : {}').format(self.active_laz.num_points))
5921
+ logging.info(_('Filter done - Nb points : {:_}').format(self.active_laz.num_points))
5896
5922
  else:
5897
5923
  logging.info(_('Filter cancelled'))
5898
5924
 
@@ -6251,7 +6277,7 @@ class WolfMapViewer(wx.Frame):
6251
6277
  """
6252
6278
 
6253
6279
  if fn is None:
6254
- filternpz = "npz (*.npz)|*.npz|LAZ (*.laz)|*.laz|LAS (*.las)|*.las|all (*.*)|*.*"
6280
+ filternpz = "LAZ (*.laz)|*.laz|LAS (*.las)|*.las|npz (*.npz)|*.npz|all (*.*)|*.*"
6255
6281
  dlg = wx.FileDialog(None, _('Choose a file containing LAS data'), wildcard=filternpz)
6256
6282
  ret = dlg.ShowModal()
6257
6283
  if ret != wx.ID_OK:
@@ -6261,12 +6287,14 @@ class WolfMapViewer(wx.Frame):
6261
6287
  fn = dlg.GetPath()
6262
6288
  dlg.Destroy()
6263
6289
 
6264
- self.mylazdata.append(Wolf_LAZ_Data())
6265
- self.active_laz = self.mylazdata[-1]
6266
- self.active_laz.from_file(fn)
6290
+ lazobj = Wolf_LAZ_Data()
6291
+ lazobj.from_file(fn)
6292
+
6293
+ self.add_object('laz', newobj= lazobj)
6267
6294
 
6268
6295
  logging.info(_('LAZ data read from file : ')+ fn)
6269
6296
  logging.info(_('Stored in internal variable'))
6297
+ logging.info(_('Nb points : {:_}').format(self.active_laz.num_points))
6270
6298
 
6271
6299
  if self.linked:
6272
6300
  if len(self.linkedList) > 0:
@@ -6882,6 +6910,7 @@ class WolfMapViewer(wx.Frame):
6882
6910
  begin = choice_bes.begin
6883
6911
  end = choice_bes.end
6884
6912
  interval = choice_bes.step
6913
+ all = choice_bes.check_all
6885
6914
 
6886
6915
  finally:
6887
6916
  choice_bes.Destroy()
@@ -6890,7 +6919,7 @@ class WolfMapViewer(wx.Frame):
6890
6919
  logging.info(_('No interval chosen - Aborting !'))
6891
6920
  return
6892
6921
 
6893
- ret = self.active_res2d.export_some_values_to_csv(all_selected, which, filename, for_steps= (begin-1, end-1, interval))
6922
+ ret = self.active_res2d.export_some_values_to_csv(all_selected, which, filename, for_steps= (begin-1, end-1, interval), all_values=all)
6894
6923
 
6895
6924
  if not ret:
6896
6925
  logging.error(_('Error in exporting values !'))
@@ -6989,7 +7018,7 @@ class WolfMapViewer(wx.Frame):
6989
7018
  logging.info(_('No interval chosen - Aborting !'))
6990
7019
  return
6991
7020
 
6992
- ret = self.active_res2d.export_some_values_to_csv(self.active_vector, which, filename=filename, for_steps= (begin-1, end-1, interval))
7021
+ ret = self.active_res2d.export_some_values_to_csv(self.active_vector, which, filename=filename, for_steps= (begin-1, end-1, interval), all_values=all)
6993
7022
 
6994
7023
  elif itemlabel == _("Plot stats unknown (inside active zone)..."):
6995
7024
 
@@ -7102,7 +7131,7 @@ class WolfMapViewer(wx.Frame):
7102
7131
 
7103
7132
 
7104
7133
  for idx, (curvect, name) in enumerate(zip(self.active_zone.myvectors, unique_name)):
7105
- self.active_res2d.export_some_values_to_csv(curvect, which, filename=directory / name, for_steps= (begin-1, end-1, interval))
7134
+ self.active_res2d.export_some_values_to_csv(curvect, which, filename=directory / name, for_steps= (begin-1, end-1, interval), all_values=all)
7106
7135
 
7107
7136
  elif itemlabel == _("Plot active vector..."):
7108
7137
  """ Plot data along active vector """
@@ -7562,13 +7591,21 @@ class WolfMapViewer(wx.Frame):
7562
7591
  autoscale=False
7563
7592
  self.clip_laz_gridded()
7564
7593
 
7594
+ if self.active_laz.nb_points ==0:
7595
+ logging.warning(_('No points in the active LAZ object -- Aborting !'))
7596
+ return
7597
+
7565
7598
  self.active_laz.create_viewer(self._choice_laz_colormap(), self.mylazgrid.colors)
7566
7599
  self.myviewerslaz.append(self.active_laz.viewer)
7567
7600
  self.active_viewerlaz = self.myviewerslaz[-1]
7568
7601
 
7569
7602
  # self.myviewer = myviewer(self.active_laz.data, ass_values[idx], palette_classif = self.mylazgrid.colors)
7570
7603
  else:
7571
- self.active_laz.create_viewer(classification= self.mylazgrid.colors)
7604
+ if self.active_laz.nb_points ==0:
7605
+ logging.warning(_('No points in the active LAZ object -- Aborting !'))
7606
+ return
7607
+
7608
+ self.active_laz.create_viewer()
7572
7609
  self.myviewerslaz.append(self.active_laz.viewer)
7573
7610
  self.active_viewerlaz = self.myviewerslaz[-1]
7574
7611
 
@@ -8812,6 +8849,8 @@ class WolfMapViewer(wx.Frame):
8812
8849
  logging.warning("Warning : the following file is not present here : " + filename)
8813
8850
  return -1
8814
8851
 
8852
+ all_ids = self.get_list_keys(None, checked_state=None)
8853
+
8815
8854
  curtree = None
8816
8855
  if which.lower() == 'array' or which.lower() == 'array_crop':
8817
8856
 
@@ -8874,18 +8913,20 @@ class WolfMapViewer(wx.Frame):
8874
8913
  testobj.read_txt_header()
8875
8914
 
8876
8915
  if testobj.wolftype in WOLF_ARRAY_MB:
8877
- with wx.lib.busy.BusyInfo(_('Importing array')):
8878
- wait = wx.BusyCursor()
8879
- newobj = WolfArrayMB(filename, mapviewer=self)
8880
- del wait
8916
+ # with wx.lib.busy.BusyInfo(_('Importing array')):
8917
+ # wait = wx.BusyCursor()
8918
+ # newobj = WolfArrayMB(filename, mapviewer=self)
8919
+ # del wait
8920
+ newobj = WolfArrayMB(filename, mapviewer=self)
8881
8921
  else:
8882
8922
  if which.lower() == 'array_crop':
8883
8923
  newobj = WolfArray(filename, mapviewer=self, crop='newcrop')
8884
8924
  else:
8885
- with wx.lib.busy.BusyInfo(_('Importing array')):
8886
- wait = wx.BusyCursor()
8887
- newobj = WolfArray(filename, mapviewer=self)
8888
- del wait
8925
+ # with wx.lib.busy.BusyInfo(_('Importing array')):
8926
+ # wait = wx.BusyCursor()
8927
+ # newobj = WolfArray(filename, mapviewer=self)
8928
+ # del wait
8929
+ newobj = WolfArray(filename, mapviewer=self)
8889
8930
 
8890
8931
  if newobj is not None:
8891
8932
  if newobj.dx==0. or newobj.dy==0.:
@@ -9398,6 +9439,7 @@ class WolfMapViewer(wx.Frame):
9398
9439
  self.mypartsystems.append(newobj)
9399
9440
  self.active_particle_system = newobj
9400
9441
 
9442
+ # ID chooser
9401
9443
  if id == '':
9402
9444
  dlg = wx.TextEntryDialog(self, 'ID ? (case insensitive)', 'Choose an identifier', '')
9403
9445
  if filename != '':
@@ -9405,26 +9447,29 @@ class WolfMapViewer(wx.Frame):
9405
9447
  else:
9406
9448
  dlg.SetValue('')
9407
9449
 
9408
- if len(curdict) == 0:
9450
+ endid = 1
9451
+ # ids = self.get_list_keys(None, checked_state=None) #[cur.idx for cur in curdict]
9452
+ while id.lower() in all_ids or id =='':
9409
9453
  if dlg.ShowModal() == wx.ID_OK:
9410
9454
  id = dlg.GetValue()
9411
9455
  if id =='':
9412
- id = '001'
9413
- else:
9414
- ids = [cur.idx for cur in curdict]
9415
- while id.lower() in ids:
9416
- if dlg.ShowModal() == wx.ID_OK:
9417
- id = dlg.GetValue()
9418
- if id =='':
9419
- id = '001'
9456
+ id = str(endid).zfill(3)
9457
+ endid += 1
9420
9458
  dlg.Destroy()
9421
9459
 
9422
- ids = [cur.idx for cur in curdict]
9423
- if id.lower() in ids:
9424
- # endid = '_'
9460
+ # ids = [cur.idx for cur in curdict]
9461
+ # if id.lower() in ids:
9462
+ # endid = 1
9463
+ # while (id + str(endid).zfill(3)).lower() in ids:
9464
+ # endid += 1
9465
+ # id = id + str(endid).zfill(3)
9466
+
9467
+ # all_ids = self.get_list_keys(None, checked_state=None)
9468
+ if id.lower() in all_ids:
9425
9469
  endid = 1
9426
9470
  while (id + str(endid).zfill(3)).lower() in ids:
9427
9471
  endid += 1
9472
+ id = id + str(endid).zfill(3)
9428
9473
 
9429
9474
  newobj.idx = id.lower()
9430
9475
 
@@ -9489,7 +9534,7 @@ class WolfMapViewer(wx.Frame):
9489
9534
  except:
9490
9535
  return None
9491
9536
 
9492
- def _get_list(self, drawing_type:draw_type):
9537
+ def _get_list(self, drawing_type:draw_type = None):
9493
9538
  """ return the list of objects of type drawing_type """
9494
9539
 
9495
9540
  # ARRAYS = 'arrays'
@@ -9506,6 +9551,10 @@ class WolfMapViewer(wx.Frame):
9506
9551
  # WMSBACK = 'wms-background'
9507
9552
  # WMSFORE = 'wms-foreground'
9508
9553
 
9554
+ if drawing_type is None:
9555
+ # return all_lists
9556
+ return self.myarrays + self.myvectors + self.myclouds + self.mytri + self.mypartsystems + self.myothers + self.myviews + self.myres2D
9557
+
9509
9558
  if drawing_type == draw_type.ARRAYS:
9510
9559
  return self.myarrays
9511
9560
  elif drawing_type == draw_type.VECTORS or drawing_type == draw_type.BRIDGES or drawing_type == draw_type.WEIRS or drawing_type == draw_type.CROSS_SECTIONS :
@@ -9536,19 +9585,27 @@ class WolfMapViewer(wx.Frame):
9536
9585
  logging.error('Unknown drawing type : ' + drawing_type)
9537
9586
  return None
9538
9587
 
9588
+ def get_list_keys(self, drawing_type:draw_type = None, checked_state:bool=True):
9589
+ """ Create a list of keys of type draw_type
9539
9590
 
9540
- def get_list_keys(self, drawing_type:draw_type, checked_state:bool=True):
9541
- """ Create a list of keys of type draw_type """
9591
+ :param drawing_type: type of object to search - If None, return all objects
9592
+ :param checked_state: if True/False, return only keys of objects that are plotted or not. None return all objects.
9593
+ """
9542
9594
 
9543
9595
  if checked_state is None:
9544
9596
  return [curobj.idx for curobj in self._get_list(drawing_type)]
9545
9597
  else:
9546
9598
  return [curobj.idx for curobj in self._get_list(drawing_type) if curobj.plotted == checked_state]
9547
9599
 
9548
- def get_list_objects(self, drawing_type:draw_type, checked_state:bool=True):
9600
+ def get_list_ids(self, drawing_type:draw_type = None, checked_state:bool=True):
9601
+ """ Alias for get_list_keys """
9602
+
9603
+ return self.get_list_keys(drawing_type, checked_state)
9604
+
9605
+ def get_list_objects(self, drawing_type:draw_type = None, checked_state:bool=True):
9549
9606
  """ Create a list of objects of type draw_type
9550
9607
 
9551
- :param drawing_type: type of object to search
9608
+ :param drawing_type: type of object to search -- If None, return all objects.
9552
9609
  :param checked_state: if True/False, return only objects that are plotted or not. None return all objects.
9553
9610
  """
9554
9611
 
@@ -10775,6 +10832,7 @@ class WolfMapViewer(wx.Frame):
10775
10832
 
10776
10833
  self.active_vector.move(delta_x, delta_y)
10777
10834
  self.active_vector.clear_cache()
10835
+ self.active_vector._move_start = None
10778
10836
  self.end_action(_('End move vector'))
10779
10837
 
10780
10838
  elif self.action == 'rotate vector':
@@ -10796,6 +10854,7 @@ class WolfMapViewer(wx.Frame):
10796
10854
 
10797
10855
  self.active_vector.rotate_xy(x, y)
10798
10856
  self.active_vector.clear_cache()
10857
+ self.active_vector._rotation_center = None
10799
10858
  self.end_action(_('End rotate vector'))
10800
10859
 
10801
10860
  elif self.action == 'move zone':
@@ -10816,6 +10875,7 @@ class WolfMapViewer(wx.Frame):
10816
10875
 
10817
10876
  self.active_zone.move(x - self.active_zone._move_start[0], y - self.active_zone._move_start[1])
10818
10877
  self.active_zone.clear_cache()
10878
+ self.active_zone._move_start = None
10819
10879
  self.end_action(_('End move zone'))
10820
10880
 
10821
10881
  elif self.action == 'rotate zone':
@@ -10830,6 +10890,7 @@ class WolfMapViewer(wx.Frame):
10830
10890
 
10831
10891
  self.active_zone.rotate_xy(x, y)
10832
10892
  self.active_zone.clear_cache()
10893
+ self.active_zone._rotation_center = None
10833
10894
  self.end_action(_('End rotate zone'))
10834
10895
 
10835
10896
  elif self.action == 'dynamic parallel':
wolfhece/PyGui.py CHANGED
@@ -217,7 +217,7 @@ class MapManager(GenMapManager):
217
217
  ToCheck=False,
218
218
  id='Land maps')
219
219
  except:
220
- logging.error("Can't load some data (hydrometry, picc, cadaster, landmaps) -- Please check the data directories and/or report the issue")
220
+ logging.warning("Can't load some data (hydrometry, picc, cadaster, landmaps) -- Please check the data directories and/or report the issue")
221
221
 
222
222
  self.mapviewer.menu_walous()
223
223