wolfhece 2.1.84__py3-none-any.whl → 2.1.86__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.
@@ -1749,7 +1749,7 @@ class vector:
1749
1749
  if self.mytree is not None:
1750
1750
  self.mytree.UncheckItem(self.myitem)
1751
1751
 
1752
- self.parentzone.reset_listogl()
1752
+ self._reset_listogl()
1753
1753
 
1754
1754
  def use(self):
1755
1755
  """
@@ -1760,7 +1760,7 @@ class vector:
1760
1760
  self.mytree.CheckItem(self.myitem)
1761
1761
 
1762
1762
 
1763
- self.parentzone.reset_listogl()
1763
+ self._reset_listogl()
1764
1764
 
1765
1765
  def fillgrid(self, gridto:CpGrid):
1766
1766
  """
@@ -1820,7 +1820,7 @@ class vector:
1820
1820
  if self.linestring is not None:
1821
1821
  self.prepare_shapely()
1822
1822
 
1823
- self.parentzone.reset_listogl()
1823
+ self._reset_listogl()
1824
1824
 
1825
1825
  def get_s2d(self):
1826
1826
  """
@@ -1844,9 +1844,12 @@ class vector:
1844
1844
 
1845
1845
  def get_sz(self,cumul=True):
1846
1846
  """
1847
- Calcule et retourne la distance horizontale cumulée ou non de chaque point vis-à-vis du premier point
1847
+ Calcule et retourne la distance horizontale cumulée ou non
1848
+ de chaque point vis-à-vis du premier point
1848
1849
 
1849
1850
  Utile pour le tracé de sections en travers ou des vérifications de position
1851
+
1852
+ :param cumul: si True, retourne la distance cumulée 2D. si False, retourne la distance 2D entre chaque point et le premier.
1850
1853
  """
1851
1854
  z = np.asarray([self.myvertices[i].z for i in range(self.nbvertices)])
1852
1855
 
@@ -1977,6 +1980,9 @@ class vector:
1977
1980
  """
1978
1981
  Création d'un nouveau vecteur sur base du découpage d'un autre et d'un pas spatial à respecter
1979
1982
  Le nouveau vecteur contient tous les points de l'ancien et des nouveaux sur base d'un découpage 3D
1983
+
1984
+ :param ds: pas spatial
1985
+ :param new: si True, le vecteur est ajouté à la zone parente
1980
1986
  """
1981
1987
  newvec = vector(name=self.myname+'_split',parentzone=self.parentzone)
1982
1988
 
@@ -1995,10 +2001,7 @@ class vector:
1995
2001
  curzone=self.parentzone
1996
2002
  if curzone is not None:
1997
2003
  curzone.add_vector(newvec)
1998
- try:
1999
- curzone.parent.fill_structure()
2000
- except:
2001
- pass
2004
+ curzone._fill_structure()
2002
2005
  else:
2003
2006
  self.myvertices = newvec.myvertices
2004
2007
  self.update_lengths()
@@ -2303,7 +2306,7 @@ class vector:
2303
2306
 
2304
2307
  return fig,ax
2305
2308
 
2306
- def deepcopy_vector(self, name: str = None, parentzone : str = None):
2309
+ def deepcopy_vector(self, name: str = None, parentzone = None):
2307
2310
  """
2308
2311
  Return a deep copy of the vector.
2309
2312
  """
@@ -2311,7 +2314,7 @@ class vector:
2311
2314
  if name is None:
2312
2315
  name = self.myname + "_copy"
2313
2316
 
2314
- if parentzone:
2317
+ if parentzone is not None:
2315
2318
  copied_vector = vector(name=name,parentzone=parentzone)
2316
2319
  else:
2317
2320
  copied_vector = vector(name=name)
@@ -2333,6 +2336,277 @@ class vector:
2333
2336
  self.myprop.legendy = centroid.y
2334
2337
  self.myprop.legendtext = text if text else self.myname
2335
2338
 
2339
+ def set_z(self, new_z:np.ndarray):
2340
+ """ Set the z values of the vertices """
2341
+ self.z = new_z
2342
+
2343
+ @property
2344
+ def z(self):
2345
+ z = np.asarray([curvert.z for curvert in self.myvertices])
2346
+ if self.add_zdatum:
2347
+ z+=self.zdatum
2348
+ return z
2349
+
2350
+ @property
2351
+ def x(self):
2352
+ return np.asarray([curvert.x for curvert in self.myvertices])
2353
+
2354
+ @property
2355
+ def y(self):
2356
+ return np.asarray([curvert.y for curvert in self.myvertices])
2357
+
2358
+ @property
2359
+ def xy(self):
2360
+ return np.asarray([[curvert.x, curvert.y] for curvert in self.myvertices])
2361
+
2362
+ @property
2363
+ def xz(self):
2364
+ return np.asarray([[curvert.x, curvert.z] for curvert in self.myvertices])
2365
+
2366
+ @property
2367
+ def xyz(self):
2368
+ return self.asnparray3d()
2369
+
2370
+ @property
2371
+ def i(self):
2372
+ return np.asarray([curvert.in_use for curvert in self.myvertices])
2373
+
2374
+ @property
2375
+ def xyzi(self):
2376
+ x = self.x
2377
+ y = self.y
2378
+ z = self.z
2379
+ i = self.i
2380
+ return np.column_stack((x,y,z,i))
2381
+
2382
+ @property
2383
+ def xyi(self):
2384
+ return np.asarray([[curvert.x, curvert.y, curvert.in_use] for curvert in self.myvertices])
2385
+
2386
+ @property
2387
+ def sz(self):
2388
+ return self.get_sz()
2389
+
2390
+ @x.setter
2391
+ def x(self, new_x:np.ndarray):
2392
+ """ Set the x values of the vertices """
2393
+
2394
+ if len(new_x) != self.nbvertices:
2395
+ logging.warning(_('New x values have not the same length as the number of vertices'))
2396
+ return
2397
+
2398
+ for curvert, newx in zip(self.myvertices, new_x):
2399
+ curvert.x = newx
2400
+
2401
+ self._reset_listogl()
2402
+
2403
+ @y.setter
2404
+ def y(self, new_y:np.ndarray):
2405
+ """ Set the y values of the vertices """
2406
+
2407
+ if len(new_y) != self.nbvertices:
2408
+ logging.warning(_('New y values have not the same length as the number of vertices'))
2409
+ return
2410
+
2411
+ for curvert, newy in zip(self.myvertices, new_y):
2412
+ curvert.y = newy
2413
+
2414
+ self._reset_listogl()
2415
+
2416
+ @z.setter
2417
+ def z(self, new_z:np.ndarray):
2418
+ """ Set the z values of the vertices """
2419
+
2420
+ if len(new_z) != self.nbvertices:
2421
+ logging.warning(_('New z values have not the same length as the number of vertices'))
2422
+ return
2423
+
2424
+ if self.add_zdatum:
2425
+ for curvert, newz in zip(self.myvertices, new_z):
2426
+ curvert.z = newz - self.zdatum
2427
+ else:
2428
+ for curvert, newz in zip(self.myvertices, new_z):
2429
+ curvert.z = newz
2430
+
2431
+ self._reset_listogl()
2432
+
2433
+ @xyz.setter
2434
+ def xyz(self, new_xyz:np.ndarray):
2435
+ """ Set the x, y, z values of the vertices """
2436
+
2437
+ if len(new_xyz) != self.nbvertices:
2438
+ logging.warning(_('New xyz values have not the same length as the number of vertices'))
2439
+ return
2440
+
2441
+ if self.add_zdatum:
2442
+ for curvert, newxyz in zip(self.myvertices, new_xyz):
2443
+ curvert.x = newxyz[0]
2444
+ curvert.y = newxyz[1]
2445
+ curvert.z = newxyz[2] - self.zdatum
2446
+ else:
2447
+ for curvert, newxyz in zip(self.myvertices, new_xyz):
2448
+ curvert.x = newxyz[0]
2449
+ curvert.y = newxyz[1]
2450
+ curvert.z = newxyz[2]
2451
+
2452
+ self._reset_listogl()
2453
+
2454
+ @xy.setter
2455
+ def xy(self, new_xy:np.ndarray):
2456
+ """ Set the x, y values of the vertices """
2457
+
2458
+ if len(new_xy) != self.nbvertices:
2459
+ logging.warning(_('New xy values have not the same length as the number of vertices'))
2460
+ return
2461
+
2462
+ for curvert, newxy in zip(self.myvertices, new_xy):
2463
+ curvert.x = newxy[0]
2464
+ curvert.y = newxy[1]
2465
+
2466
+ self._reset_listogl()
2467
+
2468
+ @xz.setter
2469
+ def xz(self, new_xz:np.ndarray):
2470
+ """ Set the x, z values of the vertices """
2471
+
2472
+ if len(new_xz) != self.nbvertices:
2473
+ logging.warning(_('New xz values have not the same length as the number of vertices'))
2474
+ return
2475
+
2476
+ if self.add_zdatum:
2477
+ for curvert, newxz in zip(self.myvertices, new_xz):
2478
+ curvert.x = newxz[0]
2479
+ curvert.z = newxz[1] - self.zdatum
2480
+ else:
2481
+ for curvert, newxz in zip(self.myvertices, new_xz):
2482
+ curvert.x = newxz[0]
2483
+ curvert.z = newxz[1]
2484
+
2485
+ self._reset_listogl()
2486
+
2487
+ @xyzi.setter
2488
+ def xyzi(self, new_xyzi:np.ndarray):
2489
+ """ Set the x, y, z, in_use values of the vertices """
2490
+
2491
+ if len(new_xyzi) != self.nbvertices:
2492
+ logging.warning(_('New xyzi values have not the same length as the number of vertices'))
2493
+ return
2494
+
2495
+ for curvert, newxyzi in zip(self.myvertices, new_xyzi):
2496
+ curvert.x = newxyzi[0]
2497
+ curvert.y = newxyzi[1]
2498
+ curvert.z = newxyzi[2] - self.zdatum if self.add_zdatum else newxyzi[2]
2499
+ curvert.in_use = newxyzi[3]
2500
+
2501
+ self._reset_listogl()
2502
+
2503
+ @xyi.setter
2504
+ def xyi(self, new_xyi:np.ndarray):
2505
+ """ Set the x, y, in_use values of the vertices """
2506
+
2507
+ if len(new_xyi) != self.nbvertices:
2508
+ logging.warning(_('New xyi values have not the same length as the number of vertices'))
2509
+ return
2510
+
2511
+ for curvert, newxyi in zip(self.myvertices, new_xyi):
2512
+ curvert.x = newxyi[0]
2513
+ curvert.y = newxyi[1]
2514
+ curvert.in_use = newxyi[2]
2515
+
2516
+ self._reset_listogl()
2517
+
2518
+ @i.setter
2519
+ def i(self, new_i:np.ndarray):
2520
+ """ Set the in_use values of the vertices """
2521
+
2522
+ if len(new_i) != self.nbvertices:
2523
+ logging.warning(_('New i values have not the same length as the number of vertices'))
2524
+ return
2525
+
2526
+ for curvert, newi in zip(self.myvertices, new_i):
2527
+ curvert.in_use = newi
2528
+
2529
+ self._reset_listogl()
2530
+
2531
+ def __str__(self):
2532
+ return self.myname
2533
+
2534
+ def __len__(self):
2535
+ return self.nbvertices
2536
+
2537
+ def __iter__(self) -> wolfvertex:
2538
+ return iter(self.myvertices)
2539
+
2540
+ def __getitem__(self, ndx:int) -> wolfvertex:
2541
+ """ Permet de retrouver un vertex sur base de son index """
2542
+ if ndx>=0 and ndx < self.nbvertices:
2543
+ return self.myvertices[ndx]
2544
+ else:
2545
+ logging.warning(_('Index out of range'))
2546
+
2547
+ def __setitem__(self, ndx:int, value:wolfvertex):
2548
+ """ Permet de modifier un vertex sur base de son index """
2549
+ if ndx>=0 and ndx < self.nbvertices:
2550
+ self.myvertices[ndx] = value
2551
+ self._reset_listogl()
2552
+ else:
2553
+ logging.warning(_('Index out of range'))
2554
+
2555
+ def __delitem__(self, ndx:int):
2556
+ """ Permet de supprimer un vertex sur base de son index """
2557
+ if ndx>=0 and ndx < self.nbvertices:
2558
+ self.myvertices.pop(ndx)
2559
+ self._reset_listogl()
2560
+ else:
2561
+ logging.warning(_('Index out of range'))
2562
+
2563
+ def append(self, other:"vector", merge_type:Literal['link', 'copy']='link'):
2564
+ """
2565
+ Append a vector to the current one
2566
+ """
2567
+
2568
+ if merge_type == 'link':
2569
+ self.myvertices.extend(other.myvertices)
2570
+ elif merge_type == 'copy':
2571
+ self.myvertices.extend(other.myvertices.copy())
2572
+ else:
2573
+ logging.warning(_('Merge type not supported'))
2574
+
2575
+ self.update_lengths()
2576
+ self._reset_listogl()
2577
+
2578
+ def cut(self, s:float, is3D:bool=True, adim:bool=True, frombegin:bool=True):
2579
+ """
2580
+ cut a vector at a given curvilinear abscissa
2581
+ """
2582
+
2583
+ newvec = vector(name=self.myname+'_cut', parentzone=self.parentzone)
2584
+ self.parentzone.add_vector(newvec, update_struct=True)
2585
+
2586
+ k,cums,lengthparts=self.get_segment(s,is3D,adim,frombegin)
2587
+
2588
+ if frombegin:
2589
+ newvec.myvertices = self.myvertices[:k+1]
2590
+ self.myvertices = self.myvertices[k:]
2591
+ else:
2592
+ newvec.myvertices = self.myvertices[k:]
2593
+ self.myvertices = self.myvertices[:k+1]
2594
+
2595
+ self.update_lengths()
2596
+ newvec.update_lengths()
2597
+
2598
+ self._reset_listogl()
2599
+
2600
+ return newvec
2601
+
2602
+ def _reset_listogl(self):
2603
+ """
2604
+ Reset the list of OpenGL display
2605
+ """
2606
+ if self.parentzone is not None:
2607
+ self.parentzone.reset_listogl()
2608
+
2609
+
2336
2610
  class zone:
2337
2611
  """
2338
2612
  Objet de gestion d'informations vectorielles
@@ -2547,7 +2821,7 @@ class zone:
2547
2821
 
2548
2822
  return i
2549
2823
 
2550
- def add_vector(self, addedvect:vector, index=-99999, forceparent=False):
2824
+ def add_vector(self, addedvect:vector, index=-99999, forceparent=False, update_struct=False):
2551
2825
  """
2552
2826
  Ajout d'une instance 'vector'
2553
2827
 
@@ -2574,6 +2848,9 @@ class zone:
2574
2848
  # NOTHING because the active vector is normally choosen by the UI or during special operations
2575
2849
  # Here, we select the first added vector
2576
2850
 
2851
+ if update_struct:
2852
+ self._fill_structure()
2853
+
2577
2854
  def count(self):
2578
2855
  """
2579
2856
  Compte le nombre de vecteurs
@@ -2936,7 +3213,7 @@ class zone:
2936
3213
 
2937
3214
  def createmultibin_proj(self, nb=None, nb2=0) -> Triangulation:
2938
3215
  """
2939
- Création d'une triangulation sur base des vecteurs par projection au plus proche du veteur central
3216
+ Création d'une triangulation sur base des vecteurs par projection au plus proche du vecteur central
2940
3217
  Tient compte de l'ordre
2941
3218
 
2942
3219
  :param nb : nombre de points de découpe des vecteurs
@@ -3220,7 +3497,14 @@ class zone:
3220
3497
  zonepolyleft.find_minmax(True)
3221
3498
  zonepolyright.find_minmax(True)
3222
3499
 
3223
- self.parent.fill_structure()
3500
+ self._fill_structure()
3501
+
3502
+ def _fill_structure(self):
3503
+ """
3504
+ Mise à jour des structures
3505
+ """
3506
+ if self.parent is not None:
3507
+ self.parent.fill_structure()
3224
3508
 
3225
3509
  def create_sliding_polygon_from_parallel(self,
3226
3510
  poly_length:float,
@@ -3503,7 +3787,7 @@ class zone:
3503
3787
  zonepolyleft.find_minmax(True)
3504
3788
  zonepolyright.find_minmax(True)
3505
3789
 
3506
- self.parent.fill_structure()
3790
+ self._fill_structure()
3507
3791
 
3508
3792
  return myparallels
3509
3793
 
@@ -4507,6 +4791,16 @@ class Zones(wx.Frame, Element_To_Draw):
4507
4791
  """
4508
4792
  self.plotted = False
4509
4793
 
4794
+ def save(self):
4795
+ """
4796
+ Sauvegarde sur disque, sans remise en cause du nom de fichier
4797
+ """
4798
+ if self.filename =='':
4799
+ logging.warning(_('No filename defined'))
4800
+ return
4801
+
4802
+ self.saveas()
4803
+
4510
4804
  def saveas(self, filename:str=''):
4511
4805
  """
4512
4806
  Sauvegarde sur disque
@@ -4742,12 +5036,12 @@ class Zones(wx.Frame, Element_To_Draw):
4742
5036
  self.binfrom3.SetToolTip(_("Create a bin/rectangular channel based on 3 vectors in the currently active zone \n Some parameters will be prompted to the user (lateral height, ...) and if a triangular mesh must be created --> Blender"))
4743
5037
  self.binfrom3.Bind(wx.EVT_BUTTON,self.Oncreatebin)
4744
5038
 
4745
- self.trifromall = wx.Button(self,label=_('Create tri from all vectors'))
4746
- self.trifromall.SetToolTip(_("Create a triangular mesh based on all vectors in the currently active zone and add the result to the GUI \n Useful in some interpolation method"))
5039
+ self.trifromall = wx.Button(self,label=_('Create triangulation'))
5040
+ self.trifromall.SetToolTip(_("Create a triangular mesh based on all vectors within the currently active zone.\nUse the vertices as they are after subdividing the vectors into a specified number of points.\nAdd the resulting mesh to the GUI.\nThis can be useful in certain interpolation methods."))
4747
5041
  self.trifromall.Bind(wx.EVT_BUTTON,self.Oncreatemultibin)
4748
5042
 
4749
- self.trifromall_proj = wx.Button(self,label=_('Create tri from all vectors (projection)'))
4750
- self.trifromall_proj.SetToolTip(_("Create a triangular mesh based on all vectors in the currently active zone and add the result to the GUI \n Useful in some interpolation method"))
5043
+ self.trifromall_proj = wx.Button(self,label=_('Create triangulation (projection)'))
5044
+ self.trifromall_proj.SetToolTip(_("Create a triangular mesh based on all vectors in the currently active zone.\nGenerate vertices by projecting the central polyline, or the nearest one if there is an even number of polylines, onto the other polylines.\nAdd the resulting mesh to the GUI.\nThis can be useful in certain interpolation methods."))
4751
5045
  self.trifromall_proj.Bind(wx.EVT_BUTTON,self.Oncreatemultibin_project)
4752
5046
 
4753
5047
  self.polyfrompar = wx.Button(self,label=_('Create polygons from parallels'))
@@ -5217,7 +5511,7 @@ class Zones(wx.Frame, Element_To_Draw):
5217
5511
  self.mapviewer.start_action('capture vertices', _('Capture vertices'))
5218
5512
  firstvert=wolfvertex(0.,0.)
5219
5513
  self.active_vector.add_vertex(firstvert)
5220
- self.active_vector.parentzone.reset_listogl()
5514
+ self.active_vector._reset_listogl()
5221
5515
  self.mapviewer.mimicme()
5222
5516
 
5223
5517
  def OnReverse(self, event:wx.MouseEvent):
@@ -5233,6 +5527,7 @@ class Zones(wx.Frame, Element_To_Draw):
5233
5527
 
5234
5528
  self.active_vector.reverse()
5235
5529
  self.fill_structure()
5530
+ self.active_vector._reset_listogl()
5236
5531
 
5237
5532
  def OnAddPar(self, event:wx.MouseEvent):
5238
5533
  """
@@ -5257,6 +5552,7 @@ class Zones(wx.Frame, Element_To_Draw):
5257
5552
  self.fill_structure()
5258
5553
  self.find_minmax(True)
5259
5554
  self.expand_tree(self.active_zone)
5555
+ self.active_zone.reset_listogl()
5260
5556
 
5261
5557
  def OncaptureandDynapar(self, event:wx.MouseEvent):
5262
5558
  """
@@ -6024,6 +6320,8 @@ class Zones(wx.Frame, Element_To_Draw):
6024
6320
  msg+=_('\n')
6025
6321
  msg+=_('Retry !\n')
6026
6322
  wx.MessageBox(msg)
6323
+ else:
6324
+ logging.warning(_('Active vector is None - Retry !'))
6027
6325
  return True
6028
6326
  return False
6029
6327
 
wolfhece/apps/version.py CHANGED
@@ -5,7 +5,7 @@ class WolfVersion():
5
5
 
6
6
  self.major = 2
7
7
  self.minor = 1
8
- self.patch = 84
8
+ self.patch = 86
9
9
 
10
10
  def __str__(self):
11
11