wolfhece 2.1.121__py3-none-any.whl → 2.1.123__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
  """
@@ -5329,7 +5355,7 @@ class WolfMapViewer(wx.Frame):
5329
5355
  except Exception as e:
5330
5356
  logging.error(_('Error in tiles import : ')+ str(e))
5331
5357
  else:
5332
- logging.warning(_('File does not exist : ')+ curfile)
5358
+ logging.warning(_('File does not exist : ')+ str(curfile))
5333
5359
  else:
5334
5360
  logging.warning(_('Bad parameter in project file - tiles'))
5335
5361
 
@@ -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:
@@ -5360,7 +5386,7 @@ class WolfMapViewer(wx.Frame):
5360
5386
  except Exception as e:
5361
5387
  logging.error(_('Error in vector import : ')+ str(e))
5362
5388
  else:
5363
- logging.info(_('File does not exist : ') + name)
5389
+ logging.info(_('File does not exist : ') + str(name))
5364
5390
  else:
5365
5391
  logging.warning(_('Bad parameter in project file - vector'))
5366
5392
 
@@ -5380,7 +5406,7 @@ class WolfMapViewer(wx.Frame):
5380
5406
  except Exception as e:
5381
5407
  logging.error(_('Error in array import : ')+ str(e))
5382
5408
  else:
5383
- logging.info(_('File does not exist : ') + name)
5409
+ logging.info(_('File does not exist : ') + str(name))
5384
5410
  else:
5385
5411
  logging.warning(_('Bad parameter in project file - array'))
5386
5412
 
@@ -5400,7 +5426,7 @@ class WolfMapViewer(wx.Frame):
5400
5426
  except Exception as e:
5401
5427
  logging.error(_('Error in cloud import : ') + str(e))
5402
5428
  else:
5403
- logging.info(_('File does not exist : ') + name)
5429
+ logging.info(_('File does not exist : ') + str(name))
5404
5430
  else:
5405
5431
  logging.warning(_('Bad parameter in project file - cloud'))
5406
5432
 
@@ -5422,7 +5448,7 @@ class WolfMapViewer(wx.Frame):
5422
5448
  except Exception as e:
5423
5449
  logging.error(_('Error in wolf2d import : ')+ str(e))
5424
5450
  else:
5425
- logging.info(_('Directory does not exist ')) + simdir
5451
+ logging.info(_('Directory does not exist ')) + str(simdir)
5426
5452
 
5427
5453
  self.menu_wolf2d()
5428
5454
  else:
@@ -5447,7 +5473,7 @@ class WolfMapViewer(wx.Frame):
5447
5473
  except Exception as e:
5448
5474
  logging.error(_('Error in gpu2d import : ')+ str(e))
5449
5475
  else:
5450
- logging.info(_('Bad directory : ') + simdir)
5476
+ logging.info(_('Bad directory : ') + str(simdir))
5451
5477
 
5452
5478
  pgbar.Update(pgbar.GetValue() + 1)
5453
5479
 
@@ -5474,9 +5500,9 @@ class WolfMapViewer(wx.Frame):
5474
5500
 
5475
5501
  self.project_pal[curid] = mypal
5476
5502
  else:
5477
- logging.warning(_('Bad palette file : ')+ name)
5503
+ logging.warning(_('Bad palette file : ')+ str(name))
5478
5504
  else:
5479
- logging.info(_('Bad parameter in project file - palette : ')+ name)
5505
+ logging.info(_('Bad parameter in project file - palette : ')+ str(name))
5480
5506
  else:
5481
5507
  logging.warning(_('Bad parameter in project file - palette'))
5482
5508
 
@@ -5504,11 +5530,11 @@ class WolfMapViewer(wx.Frame):
5504
5530
  curarray.updatepalette(0)
5505
5531
  curarray.reset_plot()
5506
5532
  else:
5507
- logging.warning(_('Bad parameter in project file - palette-array : ')+ id_array)
5533
+ logging.warning(_('Bad parameter in project file - palette-array : ')+ str(id_array))
5508
5534
  except Exception as e:
5509
5535
  logging.error(_('Error in palette-array link : ')+ str(e))
5510
5536
  else:
5511
- logging.warning(_('Bad parameter in project file - palette-array : ')+ id_pal)
5537
+ logging.warning(_('Bad parameter in project file - palette-array : ')+ str(id_pal))
5512
5538
  else:
5513
5539
  logging.warning(_('No palettes found in project file ! -- Add palette group in the .proj'))
5514
5540
  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:
@@ -7563,13 +7591,21 @@ class WolfMapViewer(wx.Frame):
7563
7591
  autoscale=False
7564
7592
  self.clip_laz_gridded()
7565
7593
 
7594
+ if self.active_laz.nb_points ==0:
7595
+ logging.warning(_('No points in the active LAZ object -- Aborting !'))
7596
+ return
7597
+
7566
7598
  self.active_laz.create_viewer(self._choice_laz_colormap(), self.mylazgrid.colors)
7567
7599
  self.myviewerslaz.append(self.active_laz.viewer)
7568
7600
  self.active_viewerlaz = self.myviewerslaz[-1]
7569
7601
 
7570
7602
  # self.myviewer = myviewer(self.active_laz.data, ass_values[idx], palette_classif = self.mylazgrid.colors)
7571
7603
  else:
7572
- 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()
7573
7609
  self.myviewerslaz.append(self.active_laz.viewer)
7574
7610
  self.active_viewerlaz = self.myviewerslaz[-1]
7575
7611
 
@@ -8813,6 +8849,8 @@ class WolfMapViewer(wx.Frame):
8813
8849
  logging.warning("Warning : the following file is not present here : " + filename)
8814
8850
  return -1
8815
8851
 
8852
+ all_ids = self.get_list_keys(None, checked_state=None)
8853
+
8816
8854
  curtree = None
8817
8855
  if which.lower() == 'array' or which.lower() == 'array_crop':
8818
8856
 
@@ -8875,18 +8913,20 @@ class WolfMapViewer(wx.Frame):
8875
8913
  testobj.read_txt_header()
8876
8914
 
8877
8915
  if testobj.wolftype in WOLF_ARRAY_MB:
8878
- with wx.lib.busy.BusyInfo(_('Importing array')):
8879
- wait = wx.BusyCursor()
8880
- newobj = WolfArrayMB(filename, mapviewer=self)
8881
- 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)
8882
8921
  else:
8883
8922
  if which.lower() == 'array_crop':
8884
8923
  newobj = WolfArray(filename, mapviewer=self, crop='newcrop')
8885
8924
  else:
8886
- with wx.lib.busy.BusyInfo(_('Importing array')):
8887
- wait = wx.BusyCursor()
8888
- newobj = WolfArray(filename, mapviewer=self)
8889
- 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)
8890
8930
 
8891
8931
  if newobj is not None:
8892
8932
  if newobj.dx==0. or newobj.dy==0.:
@@ -9399,6 +9439,7 @@ class WolfMapViewer(wx.Frame):
9399
9439
  self.mypartsystems.append(newobj)
9400
9440
  self.active_particle_system = newobj
9401
9441
 
9442
+ # ID chooser
9402
9443
  if id == '':
9403
9444
  dlg = wx.TextEntryDialog(self, 'ID ? (case insensitive)', 'Choose an identifier', '')
9404
9445
  if filename != '':
@@ -9406,26 +9447,29 @@ class WolfMapViewer(wx.Frame):
9406
9447
  else:
9407
9448
  dlg.SetValue('')
9408
9449
 
9409
- 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 =='':
9410
9453
  if dlg.ShowModal() == wx.ID_OK:
9411
9454
  id = dlg.GetValue()
9412
9455
  if id =='':
9413
- id = '001'
9414
- else:
9415
- ids = [cur.idx for cur in curdict]
9416
- while id.lower() in ids:
9417
- if dlg.ShowModal() == wx.ID_OK:
9418
- id = dlg.GetValue()
9419
- if id =='':
9420
- id = '001'
9456
+ id = str(endid).zfill(3)
9457
+ endid += 1
9421
9458
  dlg.Destroy()
9422
9459
 
9423
- ids = [cur.idx for cur in curdict]
9424
- if id.lower() in ids:
9425
- # 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:
9426
9469
  endid = 1
9427
- while (id + str(endid).zfill(3)).lower() in ids:
9470
+ while (id + str(endid).zfill(3)).lower() in all_ids:
9428
9471
  endid += 1
9472
+ id = id + str(endid).zfill(3)
9429
9473
 
9430
9474
  newobj.idx = id.lower()
9431
9475
 
@@ -9490,7 +9534,7 @@ class WolfMapViewer(wx.Frame):
9490
9534
  except:
9491
9535
  return None
9492
9536
 
9493
- def _get_list(self, drawing_type:draw_type):
9537
+ def _get_list(self, drawing_type:draw_type = None):
9494
9538
  """ return the list of objects of type drawing_type """
9495
9539
 
9496
9540
  # ARRAYS = 'arrays'
@@ -9507,6 +9551,10 @@ class WolfMapViewer(wx.Frame):
9507
9551
  # WMSBACK = 'wms-background'
9508
9552
  # WMSFORE = 'wms-foreground'
9509
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
+
9510
9558
  if drawing_type == draw_type.ARRAYS:
9511
9559
  return self.myarrays
9512
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 :
@@ -9537,19 +9585,27 @@ class WolfMapViewer(wx.Frame):
9537
9585
  logging.error('Unknown drawing type : ' + drawing_type)
9538
9586
  return None
9539
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
9540
9590
 
9541
- def get_list_keys(self, drawing_type:draw_type, checked_state:bool=True):
9542
- """ 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
+ """
9543
9594
 
9544
9595
  if checked_state is None:
9545
9596
  return [curobj.idx for curobj in self._get_list(drawing_type)]
9546
9597
  else:
9547
9598
  return [curobj.idx for curobj in self._get_list(drawing_type) if curobj.plotted == checked_state]
9548
9599
 
9549
- 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):
9550
9606
  """ Create a list of objects of type draw_type
9551
9607
 
9552
- :param drawing_type: type of object to search
9608
+ :param drawing_type: type of object to search -- If None, return all objects.
9553
9609
  :param checked_state: if True/False, return only objects that are plotted or not. None return all objects.
9554
9610
  """
9555
9611
 
@@ -10776,6 +10832,7 @@ class WolfMapViewer(wx.Frame):
10776
10832
 
10777
10833
  self.active_vector.move(delta_x, delta_y)
10778
10834
  self.active_vector.clear_cache()
10835
+ self.active_vector._move_start = None
10779
10836
  self.end_action(_('End move vector'))
10780
10837
 
10781
10838
  elif self.action == 'rotate vector':
@@ -10797,6 +10854,7 @@ class WolfMapViewer(wx.Frame):
10797
10854
 
10798
10855
  self.active_vector.rotate_xy(x, y)
10799
10856
  self.active_vector.clear_cache()
10857
+ self.active_vector._rotation_center = None
10800
10858
  self.end_action(_('End rotate vector'))
10801
10859
 
10802
10860
  elif self.action == 'move zone':
@@ -10817,6 +10875,7 @@ class WolfMapViewer(wx.Frame):
10817
10875
 
10818
10876
  self.active_zone.move(x - self.active_zone._move_start[0], y - self.active_zone._move_start[1])
10819
10877
  self.active_zone.clear_cache()
10878
+ self.active_zone._move_start = None
10820
10879
  self.end_action(_('End move zone'))
10821
10880
 
10822
10881
  elif self.action == 'rotate zone':
@@ -10831,6 +10890,7 @@ class WolfMapViewer(wx.Frame):
10831
10890
 
10832
10891
  self.active_zone.rotate_xy(x, y)
10833
10892
  self.active_zone.clear_cache()
10893
+ self.active_zone._rotation_center = None
10834
10894
  self.end_action(_('End rotate zone'))
10835
10895
 
10836
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